poj3629
//(队列)poj3629 /* #include <iostream> #include <queue> #include <algorithm> using namespace std; #define MAXN 100005 int ans[MAXN]; int main(int argc, char *argv[]) { long N,K,M,P; long i,j,count; count=0; queue<long>q; cin>>N>>K>>P; for(i=1;i<=K;i++) q.push(i); while(!q.empty()){ for(i=1;i<=N;i++){ //cout<<"??"; if(i==N) {ans[count++]=q.front();} q.pop(); for(j=1;j<=P;j++){ q.push(q.front()); q.pop(); } } } sort(ans,ans+count); for(i=0;i<count;i++) cout<<ans[i]<<endl; return 0; } //*/