题解 | #牛牛学数列3#
牛牛学数列3
https://www.nowcoder.com/practice/f65c726d081c4160a9356eabf0dc21d9
#include <stdio.h> int main() { int m,n; float sum,sum1,sum2,sum3,t,p; sum=sum1=sum2=sum3=0; scanf("%d",&n); for(m=1;m<=n;m++) { if(m%2==0) { t=m/2; sum2=4*t-1; } else { p=(m+1)/2; sum1=4*p-3; } sum3=sum3+sum1-sum2; sum1=sum2=0; sum=sum+1/sum3; } printf("%.3f",sum); return 0; }