Advertisement
Saleh127

Light oj(LO) 1234

Mar 19th, 2021
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. double ans[1000005];
  5. const int ma=1e8+1;
  6.  
  7. void fre()
  8. {
  9. double s=0.0;
  10.  
  11. for(ll i=1; i<ma; i++)
  12. {
  13. s+=(1.00/(double)i);
  14.  
  15. if(i%100==0)
  16. {
  17. ans[i/100]=s;
  18. }
  19. }
  20. }
  21.  
  22.  
  23.  
  24. int main()
  25. {
  26. ios_base::sync_with_stdio(0);
  27. cin.tie(0);
  28. cout.tie(0);
  29.  
  30. int t,cs=1;
  31. cin>>t;
  32.  
  33. fre();
  34.  
  35. while(t--)
  36. {
  37.  
  38. ll a,b,i,j,k,l;
  39.  
  40. cin>>a;
  41. b=a/100;
  42.  
  43. k=b*100+1;
  44.  
  45. double xx=ans[b];
  46.  
  47. for(i=k; i<=a; i++)
  48. {
  49. xx+=(1.00/(double)i);
  50. }
  51.  
  52. cout<<"Case "<<cs++<<": "<<fixed<<setprecision(10)<<xx<<endl;
  53. }
  54.  
  55.  
  56. return 0;
  57. }
  58. /*
  59.  
  60. #include <bits/stdc++.h>
  61. using namespace std;
  62. double k[1000000],ol=0.57721566490153286060651209;
  63. int n;
  64. int main()
  65. {
  66. k[1]=1;
  67. for(int i=2; i<1000000; i++)
  68. {
  69. k[i]=k[i-1]+1.0/i;
  70. }
  71.  
  72. int Case=1,T;
  73. scanf("%d",&T);
  74. while(T--)
  75. {
  76. scanf("%d",&n);
  77. if(n<1000000)
  78. printf("Case %d: %.10lf\n",Case++,k[n]);
  79. else
  80. printf ( "Case% d:% .10lf\n", Case ++, log (n) + 1.0/ (2 * n) + ol); // C language kinds of log (n) is ln (n)
  81. }
  82. return 0;
  83. }
  84.  
  85. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement