小爱和小艾两人组队打一只怪兽。一开始怪兽有 �n 点生命值当 �n 变成 00 或更低时怪兽就被消灭了。他们两人是同时开始攻击的小爱每分钟可以攻击 �a 下小艾每分钟可以攻击 �b 下。若 �=2a=2�=4b=4则小爱发出攻击的时刻为05 1 15 2 25 ⋯05 1 15 2 25 ⋯小艾发出攻击的时刻为025 05 075 1 125 15 ⋯025 05 075 1 125 15 ⋯攻击
#include
int main() { int n, a, b; cin >> n >> a >> b;
int time_a = 0, time_b = 0;
int damage_a = 0, damage_b = 0;
while (n > 0) {
time_a++;
damage_a += a;
n -= damage_a;
if (n <= 0) {
cout << "A" << endl;
return 0;
}
time_b++;
damage_b += b;
n -= damage_b;
if (n <= 0) {
cout << "B" << endl;
return 0;
}
if (time_a == time_b) {
damage_a *= 2;
damage_b *= 2;
}
}
cout << "C" << endl;
return 0;
原文地址: https://www.cveoy.top/t/topic/igg0 著作权归作者所有。请勿转载和采集!