19 lines
352 B
C++
19 lines
352 B
C++
#include <bits/stdc++.h>
|
|
|
|
using namespace std;
|
|
int n;
|
|
queue<int> q;
|
|
int cnt;
|
|
int main() {
|
|
cin >> n;
|
|
for (int i = 1; i <= n; i++) q.push(i);
|
|
while (q.size() > 1) {
|
|
int t = q.front();
|
|
q.pop();
|
|
cnt++;
|
|
if (cnt == 3) cnt = 0;
|
|
else q.push(t);
|
|
}
|
|
cout << q.front();
|
|
return 0;
|
|
} |