P9748题解
题目传送门
思路
这题我们可以模拟取苹果的过程。每天取
代码
# include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int n, ans1, ans2;
int main () {
ios::sync_with_stdio (0);
cin.tie (0);
cout.tie (0);
cin >> n;
while (n) { //现在还有苹果
++ ans1; //天数+1
if (n % 3 == 1 && ! ans2) //能取到最后一个苹果,且是第一次
ans2 = ans1;
n -= (n + 2) / 3; //别忘了减去拿走的苹果!
}
cout << ans1 << ' ' << ans2;
return 0;
}