私信TA

用户名:uq_22498933496

访问量:52

签 名:

等  级
排  名 2186
经  验 2362
参赛次数 0
文章发表 1
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

解题思路:

注意事项:

参考代码:

#include<stdio.h>

int main() {

int n,m;

while(scanf("%d %d",&n,&m)!=EOF) {

int s=0;

for(int i=2; i<=n; i++) {

s=(s+m)%i;

}

printf("%d\n",s+1);

}

return 0;

}

-------------------------------------------------------------------------------------------------------------

int main() {

int n,m;

int table[200];

int baoShu;

int index;

int count;

while(scanf("%d %d",&n,&m)!=EOF) {

count=n;

baoShu=0;

index=0;

for(int i=1; i<=n; i++) {

table[i]=1;

}


while(count>1) {

index++;

baoShu++;


if(index>n) {

index=1;

}

while(table[index]==0) {

index++;

if(index>n)

index=1;

}

if(baoShu==m) {

table[index]=0;

baoShu=0;

count--;

}


}

for(int i=1; i<=n; i++) {

if(table[i]==1)

printf("%d\n",i);

}


}

return 0;

}



 

0.0分

1 人评分

  评论区