Sakanako2333 @ 2022-10-26 21:46:15
#include <stdio.h>
int main(void){
int n = 0;
int k;
float sum = 0;
scanf("%d", &k);
do{
n++;
sum += (1.0 / n);
}while(sum <= k);
printf("%d", n);
return 0;
}
by zhangzhichu123456 @ 2022-10-26 21:49:14
建议把sum换成double型(来自隔壁c++的建议
by ZXXS @ 2022-10-26 21:50:10
@Sakanako2333 float精度不够,改成double
by Sakanako2333 @ 2022-10-26 21:54:38
@ZXXS 谢谢,过了!
by Sakanako2333 @ 2022-10-26 21:54:58
@zhangzhichu123456 谢谢!过了