您的位置:首页 > 其它

HDU 5879 Cure

2016-09-19 22:35 274 查看
打表,预处理。

因为只要保留$5$位小数,所以$n$大于某个数字的时候,答案都是一样的,通过寻找可以发现$n$大约为$2000000$。读入的时候需要用字符串。

#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<iostream>
using namespace std;
typedef long long LL;
const double pi=acos(-1.0),eps=1e-6;
void File()
{
freopen("D:\\in.txt","r",stdin);
freopen("D:\\out.txt","w",stdout);
}
template <class T>
inline void read(T &x)
{
char c=getchar(); x=0;
while(!isdigit(c)) c=getchar();
while(isdigit(c)) {x=x*10+c-'0'; c=getchar();}
}

const int maxn=2000010;
double a[maxn];
char s[10000010];

int get()
{
int res=0;
for(int i=0;s[i];i++)
res=res*10+s[i]-'0';
return res;
}

int main()
{
for(int i=1;i<=2000000;i++)
a[i]=a[i-1]+1.0/((double)i*(double)i);
while(~scanf("%s",s))
{
int len=strlen(s);
if(len>7) printf("%.5lf\n",a[2000000]);
else
{
int n=get();
if(n>=2000000) n=2000000;
printf("%.5lf\n",a
);
}
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: