41 lines
658 B
C++
41 lines
658 B
C++
|
//<2F><><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƹ<EFBFBD>ʽ<EFBFBD><CABD>f(n)=ln(n)+r+1.0/(2*n)
|
|||
|
//r<><72>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
//ע<>⣺<EFBFBD>˹<EFBFBD>ʽֻ<CABD><D6BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>n<EFBFBD>ܴ<EFBFBD><DCB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
#include<cstdio>
|
|||
|
#include<algorithm>
|
|||
|
#include <cmath>
|
|||
|
using namespace std;
|
|||
|
#define r 0.57721566490153286060651209//ŷ<><C5B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
const int N=1e8;
|
|||
|
const int w=1e4;
|
|||
|
double a[w+5];
|
|||
|
int t,n;
|
|||
|
int t1;
|
|||
|
double ans;
|
|||
|
inline void cun()
|
|||
|
{
|
|||
|
for(int i=1;i<=w;i++)
|
|||
|
{
|
|||
|
a[i]=a[i-1]+(1.0/i);
|
|||
|
}
|
|||
|
}
|
|||
|
int main()
|
|||
|
{
|
|||
|
cun();
|
|||
|
scanf("%d",&t);
|
|||
|
while(t--)
|
|||
|
{
|
|||
|
scanf("%d",&n);
|
|||
|
if(n<=w)
|
|||
|
{
|
|||
|
printf("Case %d: %.10lf\n",++t1,a[n]);//lf->double <20><><EFBFBD><EFBFBD>llf
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
ans=log(n)+r+1.0/(2*n);//cmath <20><>log<6F><67><EFBFBD><EFBFBD>ln
|
|||
|
printf("Case %d: %.10lf\n",++t1,ans);
|
|||
|
}
|
|||
|
}
|
|||
|
return 0;
|
|||
|
}
|