并非答案( ^ ~^)

yehongchen 2024-03-09 19:38:47 2024-03-09 19:39:07 20
include<bits/stdc++.h>
using namespace std;
struct node
{
	int id;
	int pred,next;	
}a[1005];
int m,n,k,s,head=0;
void link(int p,int q)
{
	a[p].next=q;
	a[q].pred=p;
}
int main()
{
	cin>>m>>n>>k>>s;
	for(int i=1;i<=m;i++)
	{
		a[i].id=i;
		link(i-1,i);
	}
	link(m,a[head].next);
	int p=a[s].pred,q;
	for(int i=1;i<=m;i++)
	{
		if(i%2==1){
		for(int j=1;j<n;j++)
			p=a[p].next;
			q=a[p].next;
			cout<<a[q].id<<" ";
			link(p,a[q].next);
			p=a[p].next;
		}
		else
		{
			for(int j=1;j<k;j++)
			p=a[p].pred;
			q=a[p].pred;
			cout<<a[q].id<<" ";
			link(a[q].pred,p);
			p=a[p].pred;
		}
<span class="hl-punctuation hl-section hl-block hl-end hl-c++">}</span></span>
<span class="hl-keyword hl-control hl-c++">return</span> <span class="hl-constant hl-numeric hl-c++">0</span><span class="hl-punctuation hl-terminator hl-c++">;</span>

}

{{ vote && vote.total.up }}