A 牛可乐打怪 很容易发现,当每次造成/受到的伤害为怪物血量的因子数时,受到的总伤害会是最小的。同时,用最短攻击序列消灭怪物,意味着每次造成的伤害要尽可能大。 我们可以遍历 的所有因子,找到不超过 的最大值 ,为每次造成的伤害,此时 即所求。时间复杂度 。 c++ python #include <iostream> using namespace std; int main() { int a, n; cin >> a >> n; int x = 0; int i = 1; while (i * i <= n) { if (n ...