Advertisement
S_h_u_v_r_o

Ad-hoc 1030

Dec 14th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. #include<stdio.h>
  2.  
  3. int main()
  4. {
  5. int a,b,c[10000],d,x,y,e=0,f,g;
  6. scanf("%d",&d);
  7.  
  8. for(a=1; a<=d; a++)
  9. {
  10. scanf("%d %d",&x,&y);
  11.  
  12. f=x;
  13. if(x==1){g=1;}
  14. if(y==1){g=x;}
  15. for(b=1; b<=x; b++)
  16. {
  17. c[b]=b;
  18. }
  19. while(f>=1)
  20. {
  21. for(b=1; b<=x; b++)
  22. {
  23.  
  24. if(c[b]==0){continue;}
  25. e++;
  26. if(e==y)
  27. {
  28. c[b]=0;
  29. e=0;
  30. --f;
  31. }
  32.  
  33. if(c[b]!=0){g=c[b];}
  34. }
  35. }
  36.  
  37. printf("Case %d: %d\n",a,g);
  38. }
  39.  
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement