问题类型:一次性AC
03pie’s solution for [HDU-2011]:
问题链接
#include<cstdio>
const int maxn=1000;
using namespace std;
int main(){
int n;
while(~scanf("%d",&n)){
while(n--){
int x;
double ans=0;
scanf("%d",&x);
for(int i=1;i<=x;i++){
double i1=i;
if(i&1){ans+=(1/i1);}
else {ans-=(1/i1);}
}
printf("%.2f\n",ans);
}
}
return 0;
}