-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathp131.c
43 lines (41 loc) · 983 Bytes
/
p131.c
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
/* Llenando piscinas */
#include <stdio.h>
#include <limits.h>
int llenado(int p, int b, int v) {
int num, aux, sol = 0;
if(v > b-1 && p > b)
return INT_MAX;
else if(b > p-1)
return 1;
while(p > 0) {
num = p / b;
sol = sol + num;
aux = p - (num*b) + num*v;
if(aux < 1)
return sol;
if(aux < b+1) {
sol++;
return sol;
}
p = aux;
}
}
int main() {
int p1, b1, v1, s1, p2, b2, v2, s2;
while(1) {
scanf("%d %d %d %d %d %d", &p1, &b1, &v1, &p2, &b2, &v2);
if(p1 == 0 || p2 == 0)
return 0;
s1 = llenado(p1, b1, v1);
s2 = llenado(p2, b2, v2);
if(s1 < s2)
printf("YO %d\n", s1);
else if(s1 > s2)
printf("VECINO %d\n", s2);
else
if(s1 == INT_MAX)
printf("EMPATE 0\n");
else
printf("EMPATE %d\n", s1);
}
}