Cameron_python @ 2024-09-08 15:12:32
#include <iostream>
using namespace std;
int main()
{
int k;cin >> k;
int cnt = 0,n = 0;
while(cnt < k)
{
n++;
for(int i = n;i <= n;i++)
{
cnt += 1.0 * 1 / i;
}
cnt = 0;
}
cout << n;
return 0;
}
by litangzheng @ 2024-09-08 15:19:14
呃,就是穷举啊,为什么会超时
by cgxd @ 2024-09-08 15:24:04
这题k很小,打表就能过
by Ryan888 @ 2024-09-08 15:42:14
while循环条件是 cnt < k,最后一句又把cnt赋值为零,是s循环。
by YuYi_official @ 2024-09-21 19:25:15
你的代码在本地运行很吃cpu,写成死循环了吧?