Advertisement
rafid_shad

1030

Oct 28th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.04 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6.     int x,y,i,store,j;
  7.     int n;
  8.     cin>>n;
  9.     for(int k=1; k<=n; k++)
  10.     {
  11.         cin>>x>>y;
  12.         int a[x];
  13.         fill( a, a+x, 0 );
  14.  
  15.         int count1=0;
  16.         store=0;
  17.         while(1)
  18.         {
  19.             for(j=0; j<x; j++)
  20.             {
  21.                 count1++;
  22.  
  23.                 if(a[j]==1)
  24.                 {
  25.                     count1--;
  26.  
  27.                     continue;
  28.                 }
  29.                 if(count1==y)
  30.                 {
  31.                     store=j;
  32.                 }
  33.                 if(count1==y+1)
  34.                 {
  35.                     a[j]=1;
  36.                     count1=1;
  37.                 }
  38.             }
  39.  
  40.             int mycount = count (a, a+x, 1);
  41.             if(mycount==x-1)
  42.             {
  43.                 break;
  44.             }
  45.  
  46.         }
  47.         if(store==0)
  48.         {
  49.             cout<<"Case "<<k<<": "<<x<<endl;
  50.         }
  51.         else
  52.  
  53.         cout<<"Case "<<k<<": "<<store<<endl;
  54.  
  55.     }
  56.     return 0;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement