You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
334 B

#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;
}