周赛小记2023.9.11

P2021 faebdc玩扑克

如果这个位置之前放过数,那么此处的隔位就不能算进去,相隔的位置应该继续增加

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

猜你喜欢

转载自blog.csdn.net/m0_75087931/article/details/132818580