Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int a,b,c[10000],d,x,y,e=0,f,g;
- scanf("%d",&d);
- for(a=1; a<=d; a++)
- {
- scanf("%d %d",&x,&y);
- f=x;
- if(x==1){g=1;}
- if(y==1){g=x;}
- for(b=1; b<=x; b++)
- {
- c[b]=b;
- }
- while(f>=1)
- {
- for(b=1; b<=x; b++)
- {
- if(c[b]==0){continue;}
- e++;
- if(e==y)
- {
- c[b]=0;
- e=0;
- --f;
- }
- if(c[b]!=0){g=c[b];}
- }
- }
- printf("Case %d: %d\n",a,g);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement