又是一道名为loop的题.......
首先我想的是(n-1)/2 然后就信心满满地交了上去.....之后就是WAWAWAWAWAWAWA......>
后来经过指点,才知道应该是1+1/2+1/3+1/4+1/5+.......1/n=
1 #include<iostream> 2 #include<cmath> 3 #include<cstdio> 4 #include<cstdlib> 5 6 using namespace std; 7 8 const double euler=0.57721566490; 9 10 long long n; 11 int m; 12 13 int main() { 14 freopen("loop.in","r",stdin); 15 freopen("loop.out","w",stdout); 16 scanf("%I64d%d",&n,&m); 17 if(n<5000000) { 18 double ans=0.0; 19 for(int i=1;i<=n;i++) 20 ans+=(1.0/i); 21 printf("%d ",(int)floor(ans*m - (1e-8))); 22 } else { 23 printf("%d ",(int)floor((log(n)+euler)*m - (1e-8))); 24 } 25 return 0; 26 }