-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaoj1159.cpp
More file actions
50 lines (48 loc) · 760 Bytes
/
aoj1159.cpp
File metadata and controls
50 lines (48 loc) · 760 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <cstring>
#include <cctype>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <complex>
using namespace std;
int main() {
while(1) {
int n, p;
cin >> n >> p;
if(n==0 && p==0) break;
int player[n];
for(int i=0; i<n; i++) player[i] = 0;
int i=0;
int num = p;
while(1) {
i = i%n;
if(num!=0) {
player[i]++;
num--;
if(player[i] == p) {
cout << i << endl;
break;
}
}
else {
int temp = player[i];
player[i] = 0;
num += temp;
}
i++;
}
}
return 0;
}