题解:P11577 [CCC2020] Epidemiology
1.题目描述
有
2.思路
简单模拟即可。我们用变量
3.注意事项
- 退出循环时,
i 的值是感染P 个人后的第二天。所以答案是i-1 。
4.代码
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int p, n, r;
cin >> p >> n >> r;
int d = n, i;
for (i = 1; n <= p; i++) {
d *= r;
n += d;
}
cout << i-1 << endl;
return 0;
}
5.时间复杂度
循环变量
The End