Files
python/TangDou/CSP-J/J-2023/apple_BruteForce.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

36 lines
992 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include <bits/stdc++.h>
using namespace std;
const int N = 1000010; // 90分,数组不能再大了~
int st[N];
int cnt; // 已经取出的个数
int day; // 第n个苹果是第day天被取走的
int all; // 一共需要多少天
int main() {
// freopen("apple.in", "r", stdin);
// freopen("apple.out", "w", stdout);
int n;
cin >> n;
while (true) {
// 模拟每一天
all++;
int c = 0;
for (int i = 1; i <= n; i++) {
if (st[i]) continue;
c++;
if (c % 3 == 1) { // 找规律,1,4,7,10...出列
st[i] = 1;
cnt++; // 又出队一个
if (i == n) day = all; // 记录n是哪天出队的
}
}
if (cnt == n) break; // 如果出队数量达标就完事
}
// 输出一共需要多少天,取出第n号在第几天
cout << all << " " << day << endl;
return 0;
}