HDU 5879 Cure
2016-09-19 22:35
274 查看
打表,预处理。
因为只要保留$5$位小数,所以$n$大于某个数字的时候,答案都是一样的,通过寻找可以发现$n$大约为$2000000$。读入的时候需要用字符串。
因为只要保留$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; }
相关文章推荐
- Activity的启动
- POJ 3132
- 海量数据中找出出现次数最多的前10个URL
- iOS 简单播放音效
- Java资源大全中文版(Awesome最新版)
- eclipse安装WindowBuilder
- 为什么匿名内部类和局部内部类只能访问final变量
- 使用输入流写一个对象
- Js文件中调用其它Js函数的方法
- getElmentsByClassName用法
- 校招第二站-----爱数
- HDU 2824
- 第五百零九天 how can I 坚持
- HDU 5882 Balanced Game
- [javaEE] 反射-通过反射了解集合泛型本质
- 判断一个点是否在三角形内
- 性能测试工具总结
- 抽象类与接口的思考
- Makefile中指示符“include”、“-include”和“sinclude”的区别
- 用Spring MVC开发简单的Web应用