3
/*直接链表模拟 */ #include<cstdio> #include<iostream> #define M 100010 using namespace std; int next[M],fa[M],vis[M],n,t; int main() {//freopen("jh.in","r",stdin);//freopen("resist.in","r",stdin);//freopen("resist.out","w",stdout);scanf("%d%d",&n,&t);for(int i=1;i<n;i++)next[i]=i+1;next[n]=1;for(int i=2;i<=n;i++)fa[i]=i-1;fa[1]=n;int sta=1;for(int i=1;i<n;i++){int p=sta;for(int j=1;j<t;j++)p=next[p];vis[p]=1;next[fa[p]]=next[p];fa[next[p]]=fa[p];sta=next[p];}for(int i=1;i<=n;i++)if(!vis[i])printf("%d",i);return 0; }