xiaohy_cd @ 2024-08-06 15:26:35
#include <bits/stdc++.h>
using namespace std;
int main()
{
double a=1;
int n=2,k;
cin >> k;
for(int i=2;a<=k;i++)
{
a+=1/k;
}
cout << a;
}
by lintianhong @ 2024-08-06 16:01:33
不谢
by caizhiyan @ 2024-08-06 16:06:27
@xiaohy_cd sorry 搞错了AC代码已附上
by guoyanwei120223 @ 2024-08-13 17:15:39
这样写
#include<bits/stdc++.h>
using namespace std;
int main()
{
int k,n,cnt=0;
cin>>k;
for(double sn=0;sn<=k;cnt++,sn+=1.0/cnt);
cout<<cnt;
return 0;
}
求关