#1189029

Solution for 1159: Next Mayor by capythm

Source Code Status Test Cases
    Policy: public     Reviewed: 200    
00.06 sec    1160 KB    30 lines     461 bytes    2015-01-17 00:37
#include <iostream>
using namespace std;
int main( void )
{
  while( 1 ){
    int n,p,d[55],b,i;
    cin >> n >> p;
    if( n == 0 ) break;
    for( i=0; i<n; i++ ){
      d[i] = 0;
    }
    b = p;
    i = 0;
    while( 1 ){
      if( b > 0 ){
        d[i]++;
        b--;
        if( d[i] == p ){
          cout << i << endl;
          break;
        }
      } else if( d[i] > 0 ) {
        b = d[i];
        d[i] = 0;
      }
      i = (i+1) % n;
    }
  }
}

Compile Error Logs:
You are not authorized to see the message.

Status
Judge: 1/1 C++ CPU: 00.06 sec Memory: 1160 KB Length: 461 B 2015-01-17 00:37 2015-01-17 00:37
Results for testcases
Case # Verdict CPU Time Memory In Out Case Name
Case #1: : Accepted 00.06 sec 1160 KB
< prev | / | next >  
 
Judge Input #  ( | ) Judge Output #  ( | )


Comments
 
 Under Construction.
 
Categories
 
 
Free Tags