RYIP在线题库
首 页   >   习题练习   >   提交
Problem1773--调和级数

1773: 调和级数

[Creator : ]
Time Limit : 1.000 sec  Memory Limit : 128 MB

【 Description 】

输入n,求 s=1+1/2+1/3+1/4+...+1/n 的值

【 Input 】

输入n,1<=n<=1000

【 Output 】

输出对应的s的值,保留小数点后两位

【 Sample Input 】

2

【 Sample Output 】

1.50

【HINT】

保留2位小数方法

1、在文件开始加入头文件 #include <cstdio>

2、将cout语句改用printf,例如p保留2位小数,可以用 printf("%.2f",p);

【 Source/Category 】