解题思路:
注意事项:
参考代码:
#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 人评分
用筛法求之N内的素数。 (C语言代码)浏览:868 |
1113题解浏览:798 |
C语言程序设计教程(第三版)课后习题10.3 (C语言代码)浏览:1940 |
C二级辅导-公约公倍 (C语言代码)浏览:499 |
分糖果 (C语言代码)浏览:923 |
淘淘的名单 (C语言代码)浏览:1234 |
简单的a+b (C语言代码)浏览:836 |
2003年秋浙江省计算机等级考试二级C 编程题(2) (C语言代码)浏览:729 |
C语言程序设计教程(第三版)课后习题3.7 (C语言代码)浏览:382 |
1199题解浏览:660 |