P2021 faebdc plays poker
If the number has been placed in this position before, then the interval here cannot be counted, and the interval should continue to increase.
#include<bits/stdc++.h>
using namespace std;
const int N = 1e8 + 10;
int n, s, a[N];
int main()
{
cin >> n;
for(int i = 1; i <= n; i ++)
{
for(int j = 1; j <= 2; j ++)
{
s ++;
if(s > n)s = 1;
if(a[s] != 0)j --;
}
a[s] = i;
}
for(int i = 1; i <= n; i ++)cout << a[i] << ' ';
return 0;
}