题目链接:https://ac.nowcoder.com/acm/contest/992/F
题意:给定正n边形,边长为100,以每条边的中点连线构成新的正n边形,无限循环下去,求所有边的长度和。
思路:简单数学计算题,可以发现每往下进行一层,边长减小cos(PI/n)倍,在n趋于无穷求等比数列和即可。
AC代码:
#include<cstdio>
#include<cmath>
using namespace std;
const double PI=acos(-
1);
int n;
int main(){
while(~scanf(
"%d",&
n)){
double r=PI/
n;
printf("%.2f\n",
100.0*n/(
1.0-
cos(r)));
}
return 0;
}
转载于:https://www.cnblogs.com/FrankChen831X/p/11186043.html