求帮助
查看原帖
求帮助
1454269
HuangYouMing楼主2024/12/19 19:05
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector<int> apples(n);
    for (int i = 0; i < n; ++i) {
        apples[i] = i + 1;
    }
    int day = 0;
    int target_day = 0;
    while (!apples.empty())  {
        day++;
        vector<int> new_apples;
        for(int i = 0; i < apples.size();  ++i) {
            if ((i + 1) % 3!= 1) {
                new_apples.push_back(apples[i]);
                if (apples[i] == n) {
                    target_day = day;
                }
            }
        }
        apples = new_apples;
    }
    cout << day << " " << target_day+1 << endl;
    return 0;
}

2024/12/19 19:05
加载中...