思路
这个题的算式和冰雹猜想一模一样,最后循环节一定是4 -> 2 -> 1,只要m等于4,2,1中的任意就一定会进入这个循环节
然后假设剩余的单词数为n,则所需的天数就是(n / 7) * 3, 然后在对n进行取模最后的循环次数一定不会超过三次
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n, m, ans = 0;
void solve() {
cin >> n >> m;
while (n > 0) {
ans ++;
n -= m;
if (m % 2)
m = m * 3 + 1;
else
m /= 2;
// 跟冰雹猜想一样,最后得到的m一定是4→2→1也就是对应的7个单词持续了3天
if (m == 1 || m == 2 || m == 4) {
ans += (n / 7) * 3;
n %= 7;
}
}
cout << ans << '\n';
}
int main() {
cin.tie(0);cout.tie(0);ios::sync_with_stdio(0);
int T = 1;
//cin >> T;
while (T -- ) solve();
return 0;
}