个人博客:doubleq.win
#include<iostream> #include<cstring> using namespace std; int a[1001]; int b[1001]; int main() { int flag=0; int tn=0; int n,m; while(true) { memset(a,0,sizeof(a)); cin>>n>>m; if(n==0&&m==0)break; else { int tot=n; int now=0; int cur=0; while(tot!=1) { if(a[cur]==0) { now++; } if(now==m) { now=0; a[cur]=1; tot--; } cur++; if(cur==n)cur=0; } } for(int i=0;i<n;i++) if(a[i]!=1) { b[tn]=i+1; tn++; } } for(int i=0;i<=999;i++) { if(b[i]!=0)cout<<b[i]<<endl; else break; } return 0; }
个人QQ:757394026
团队QQ:466373640
个人博客:www.doubleq.win
c++/noi/信息学奥数博客:http://www.cnblogs.com/zwfymqz