为什么超时了?https://www.luogu.com.cn/training/102#problems
#include <bits/stdc++.h>
using namespace std;
int main ( ){
int k;
cin >> k;
double n=1;
int i=1;
while(n<=k){
n=n+1/i;
i++;
}
cout << n;
return 0;
}如有帮助,我必关注。
为什么超时了?https://www.luogu.com.cn/training/102#problems
#include <bits/stdc++.h>
using namespace std;
int main ( ){
int k;
cin >> k;
double n=1;
int i=1;
while(n<=k){
n=n+1/i;
i++;
}
cout << n;
return 0;
}如有帮助,我必关注。