P9748题解
数学题。
题意:有
因为是隔两个拿一个,所以设苹果数量为
考场代码:
#include <bits/stdc++.h>
using namespace std;
int main() {
//freopen("apple.in", "r", stdin);
//freopen("apple.out", "w", stdout);
long long n;
cin >> n;
long long ans1 = 0, ans2 = 0;
bool y = 0;
long long nn = n;
if (n % 3 == 1) {
ans2 = 1;
y = 1;
}
while (nn) {
ans1++;
nn -= (nn - 1) / 3 + 1;
if ((nn - 1) % 3 == 0 && y == 0) {
y = 1;
ans2 = ans1 + 1;
}
}
cout << ans1 << ' ' << ans2 << endl;
return 0;
}