this a basic maths question
spoj link
solution follows
spoj link
solution follows
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include<bits/stdc++.h> int min(int x,int y) { return (x<y)?x:y; } int main() { int t,n; scanf("%d",&t); double a[100005]={0}; for(int i=1;i<=100000;i++) a[i]+=a[i-1]+(double)((double)1/i); while(t--) { scanf("%d",&n); printf("%0.2lf\n",n*a[n] ); } return 0; } |
No comments:
Post a Comment