1 条题解
-
0
【例17.3】 内功逼毒
解题思路
在 t 时间内最多逼出 t×m 点毒。将这个量与 n 比较,达到 n 即能在时限内完成。
正确性说明
t×m≥n 等价于完成所需时间不超过 t,正是得救条件。
易错点
恰好等于时限也算能得救,使用 >=。
复杂度
输入规模固定,时间 O(1),额外空间 O(1)。
参考代码(C++11)
#include <bits/stdc++.h> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); long long t, n, m; cin >> t >> n >> m; cout << (t * m >= n ? "yes" : "no") << "\n"; return 0; }
- 1