hdu_2156
递推就行啦啦啦啦啦
代码如下:
1 #include <stdio.h> 2 #include <stdlib.h> 3 4 int main() 5 { 6 double value[50000], sum; 7 int i, n; 8 9 value[1] = 1; 10 value[2] = 3; 11 for( i = 3, sum = 1.0 / 2 + 1.0 / 3; i < 50000; i ++ ) 12 { 13 value[i] += value[i-1] + 1.0 + sum * 2.0; 14 sum += 1.0 / ( i + 1.0 ); 15 } 16 while( scanf( "%d", &n ), n ) 17 { 18 printf( "%.2lf\n", value[n] ); 19 } 20 return 0; 21 }