zhanchengwen @ 2022-05-05 16:44:23
此题 1≤k≤15 ,那么能否用打表?
by zhanchengwen @ 2022-05-05 16:45:31
最后2个位数更多,星号就没了
by zhanchengwen @ 2022-05-05 16:47:38
@JustinXiaoJunyang ,我是AC一遍再打表的
by JustinXiaoJunyang @ 2022-05-05 16:47:51
@zhanchengwen 不用打表吧,求关注~
#include <iostream>
#include <cstdio>
using namespace std;
int main()
{
int k, i = 0;
double s = 0.0;
cin >> k;
do
{
i++;
s += (1.0 / i);
} while (s <= k);
cout << i << endl;
return 0;
}
尽量不要打表,要锻炼思维。
by JustinXiaoJunyang @ 2022-05-05 16:48:31
@zhanchengwen 您甚至可以利用你的程序验证
by JustinXiaoJunyang @ 2022-05-05 16:49:07
@zhanchengwen 以后 OI 数据范围很大,要用算法。
by JustinXiaoJunyang @ 2022-05-05 16:50:15
@zhanchengwen 像 P1009 也可以打表,就是麻烦
by zhanchengwen @ 2022-05-06 07:15:27
@JustinXiaoJunyang 知道了,谢谢!
by AOBaob @ 2022-05-09 11:10:29
求助for循环为啥TLE了