本题使用队列来解决 另外请同学们在submit时稍微改一下格式 要不然会被判定为抄袭o、哦
#include<bits/stdc++.h>
using namespace std;
queue<int>q;
int a[100005],tot=0;
int main()
{
int n,k,p;
cin>>n>>k>>p;
int m,i,j;
m=k/n;
for(i=1;i<=k;i++)
q.push(i);
int x,y;
y=1;
while(!q.empty() /*q.size()*/)
{
x=q.front() ;
q.pop();
y--;
if(y==0) y=n;
if(y==1) a[++tot]=x;
for(j=1;j<=p;j++){
x=q.front() ;
q.pop();
q.push(x);
}
}
sort(a+1,a+tot+1);
for(i=1;i<=tot;i++)
{
cout<<a[i]<<endl;
}
return 0;
}