LightOJ 1234 Harmonic Number 分布式打表
2016-08-30 23:20
295 查看
分布均匀的打表可以有效提高速度。
输出使用%f,输入使用%lf。
题目链接:http://acm.hust.edu.cn/vjudge/problem/26945
输出使用%f,输入使用%lf。
题目链接:http://acm.hust.edu.cn/vjudge/problem/26945
#pragma comment(linker,"/STACK:1024000000,1024000000") #include<cstdio> #include<iostream> #include<sstream> #include<cstdlib> #include<cmath> #include<cctype> #include<string> #include<cstring> #include<algorithm> #include<stack> #include<queue> #include<set> #include<map> #include<ctime> #include<vector> #include<fstream> #include<list> using namespace std; #define ms(s) memset(s,0,sizeof(s)) typedef unsigned long long ULL; typedef long long LL; const int INF = 0x3fffffff; double num[1000010]; int main() { // freopen("F:\\input.txt","r",stdin); // freopen("F:\\output.txt","w",stdout); // ios::sync_with_stdio(false); ms(num); int t; int n; double ans = 0; for(int i = 1; i <= 100000000; ++i){ ans += 1.0/(double)i; if(i%100 == 0) num[i/100] = ans; } scanf("%d",&t); for(int cas = 1; cas <= t; ++cas){ scanf("%d",&n); ans = num[n/100]; for(int i = n/100*100+1; i <= n; ++i){ ans += 1.0/(double)i; } printf("Case %d: %.10f\n",cas,ans); } return 0; }
相关文章推荐
- lightoj 1234 - Harmonic Number(技巧打表)
- LightOJ 1234 Harmonic Number(打表 + 技巧)
- LightOJ 1234 Harmonic Number (打表)
- LightOJ 1234 - Harmonic Number (打表)
- lightoj 1234 - Harmonic Number 【分块打表】
- 【LightOJ - 1234】 Harmonic Number 【调和级数求前n项和---分块打表】
- kuangbin专题十四 LightOJ1234 打表
- LightOJ 1234 Harmonic Number (调和级数水题)
- LightOJ - 1234 Harmonic Number
- LightOJ - 1234 Harmonic Number 分块打表的方法
- LightOJ1234 Harmonic Number
- LightOJ 1234 Harmonic Number
- LightOJ 1234 Harmonic Number
- lightoj 1234 Harmonic Number
- lightoj1234 分段打表
- LightOJ 1234 Harmonic Number
- LightOJ - 1234 Harmonic Number【调和级数求和】
- D - Harmonic Number——(LightOJ 1234)
- LightOJ 1234 Harmonic Number(调和级数求和)
- LightOJ 1234 Harmonic Number