- #include <cstdio>
- using namespace std;
- #define MS 100000
- int main(){
- //freopen("input.txt", "r", stdin);
- int test, cs= 1;
- int n;
- double h[MS+1];
- scanf("%d", &test);
- h[0] = 0.0;
- double nh = 1.0;
- int ind = 1000;
- for(int i = 2; i <= 100000000; i++){
- nh += 1.0/i;
- if(i == ind){
- h[ind/1000] = nh;
- ind += 1000;
- }
- }
- while( test-- ){
- scanf("%d", &n);
- nh = h[n/1000];
- for(int i = (n/1000) * 1000 + 1 ; i <= n; i++)
- nh += 1.0/i;
- printf("Case %d: %.10lf\n", cs++, nh );
- }
- return 0;
- }
Friday 28 July 2017
Lightoj 1234 - Harmonic Number
Subscribe to:
Post Comments (Atom)
Most Featured Post
Lightoj 1159 - Batman
http://lightoj.com/volume_showproblem.php?problem=1159 problem analysis: First i thought of this as if s1, s2 and s3 are those three str...
-
Problem link: Problem Analysis: It is actually a basic Bisection problem , as we can see here we can not actually find a formula fo...
-
http://lightoj.com/volume_showproblem.php?problem=1382 Problem analysis: This is a rare problem i wrote about so far. After much strugg...
No comments:
Post a Comment