HDU - 5879 Cure

https://vjudge.net/problem/HDU-5879
多次测试,在120000之后的结果都是一样的

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int n;
int main()
{
    
    
	double n;
	double sum;
	while(scanf("%lf",&n)!=EOF)
	{
    
    
		sum=0;
		for(int i=1;i<=n;i++)
		{
    
    
			sum+=1/pow(i,2);
			if(i>120000)
				break;
		}
		printf("%.5lf\n",sum);
	}
	return 0;
}

猜你喜欢

转载自blog.csdn.net/weixin_52341477/article/details/121039013
hdu