牛客编程巅峰赛S1第8场 - 青铜&白银 翻滚吧牛牛(一)

class Solution { public: /** * * @param k int整型 翻滚次数 * @return double浮点型 */ double circumference(int k) { // write code here double pi = 3.1415926535898; double s[] = { pi / 3.0, sqrt(3.0) * pi / 3.0, 2.0 * pi / 3.0, sqrt(3.0) * pi / 3.0, pi / 3.0,0.0 }; double r = 0; for (int i = 1; i <= k; i++) { r += s[(i - 1) % 6]; } return r; } };

    推荐阅读