题解 | #牛牛学数列3#
牛牛学数列3
http://www.nowcoder.com/practice/f65c726d081c4160a9356eabf0dc21d9
#include<stdio.h> #include<math.h> int main() { int n,i,j; double sum=0; scanf("%d",&n); for(i=1;i<=n;i++){ int num=0; for(j=1;j<=(2*i-1);j+=2){ num=num+(j*(pow(-1,((j+1)/2-1)*j))); } sum=sum+(1.0/num); } printf("%.3f\n",sum); return 0; }