标签:表示 pid += c++ acm for print bit 测试
http://acm.hdu.edu.cn/showproblem.php?pid=2011
#include <bits/stdc++.h>
using namespace std;
double A(int n)
{
double sum=0;
if(n==1)
return 1;
else
{
for(int j=2; j<=n; j++)
{
if(j%2==0)
sum+=(-1)*1.0/j;
else
sum+=1.0/j;
}
return (sum+1);
}
}
int main()
{
int m;
cin>>m;
for(int i=1; i<=m; i++)
{
int x;
cin>>x;
printf("%.2f\n",A(x));
}
return 0;
}
标签:表示 pid += c++ acm for print bit 测试
原文地址:https://www.cnblogs.com/zlrrrr/p/9215589.html