int main(void) { int n =41,m=3; LHead *list_head; list_head = (LHead*)malloc(sizeof(LHead)); CreatList(&list_head,n); Print(&list_head); printf("\n约瑟夫问题(人数 %d 人,序号为 %d 的倍数的人自杀)的解为:\n",n,m); Josephus(&list_head,n,m); }
int main(){ int dp[110]; int i,j; for(i=13;i<100;i++){ for(j=1;j<=2*i;j++){ // printf("%d %d\n",i,j); if(Josephus(i,j)){ dp[i]=j; break; } } } int n; while(scanf("%d",&n)!=EOF&&n)printf("%d\n",dp[n]); return 0; }