出题人题解。
思路
按照题意模拟即可,但需要考虑每一轮的状态。
AC code
#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int n, a, b, k, c, d; // 如题
cin >> n >> a >> b >> k >> c >> d;
if (n < 3) // 直接吃完,不玩逗猫棒
{
cout << 0 << endl;
return 0;
}
int ans = 0, need = 3, e = k, st = 0; // ans 为总游玩时间,need为要吃的猫粮,e为精力,st为连续次数
bool nextrest = 0; // 表示是否需要休息
while (n > need)
{
if (nextrest) // 休息回合
{
nextrest = 0;
e = k;
st = 0;
}
else // 玩和进食
{
e--;
st++;
int play = b;
if (st == c)
{
play += d;
st = 0;
}
ans += play;
if (e == 0) nextrest = 1;
}
n -= need;
need += a;
}
cout << ans << endl;
return 0;
}