Arqiu @ 2019-02-07 16:37:03
c++
int N, K;
double Sn;
cin >> K;
while(Sn <= K){
N++;
Sn += 1.0/N; //一定要1.0
}
cout << N;
return 0;
如果用1的话就会出错...
by Celestial_Scarlet @ 2019-02-07 16:40:21
@Arqiu N和1类型都是int,所以1/N会按整除处理
by Arqiu @ 2019-02-07 16:53:05
@baoyu 懂了!感谢大佬一语道破╭(′▽`)╯