Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main()
- {
- int x,y,i,store,j;
- int n;
- cin>>n;
- for(int k=1; k<=n; k++)
- {
- cin>>x>>y;
- int a[x];
- fill( a, a+x, 0 );
- int count1=0;
- store=0;
- while(1)
- {
- for(j=0; j<x; j++)
- {
- count1++;
- if(a[j]==1)
- {
- count1--;
- continue;
- }
- if(count1==y)
- {
- store=j;
- }
- if(count1==y+1)
- {
- a[j]=1;
- count1=1;
- }
- }
- int mycount = count (a, a+x, 1);
- if(mycount==x-1)
- {
- break;
- }
- }
- if(store==0)
- {
- cout<<"Case "<<k<<": "<<x<<endl;
- }
- else
- cout<<"Case "<<k<<": "<<store<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement