forked from MiYazJE/Acepta-el-reto
-
Notifications
You must be signed in to change notification settings - Fork 0
/
p131.java
58 lines (44 loc) · 1.47 KB
/
p131.java
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
51
52
53
54
55
56
57
58
import java.util.Scanner;
/**
* @author Rubén Saiz
*/
public class p131 {
private static int getViajes(int piscina, int barreno, int pierde) {
if (pierde >= barreno && barreno < piscina) return Integer.MAX_VALUE;
else if (barreno >= piscina) return 1;
int viajes = 0, aux, rest;
while (piscina > 1) {
aux = piscina / barreno;
rest = aux * pierde;
piscina = (piscina - (aux * barreno)) + rest;
viajes += aux;
if (piscina != 0 && piscina <= barreno) {
viajes++; break;
}
}
return viajes;
}
public static void main(String[] args) {
final Scanner s = new Scanner(System.in);
int pisA, barrA, piA, pisB, barrB, piB;
int yo, vecino;
while (true) {
pisA = s.nextInt();
barrA = s.nextInt();
piA = s.nextInt();
pisB = s.nextInt();
barrB = s.nextInt();
piB = s.nextInt();
if (pisA == 0 || pisB == 0) break;
yo = getViajes(pisA, barrA, piA);
vecino = getViajes(pisB, barrB, piB);
/*if (yo == -1 && vecino == -1) {
yo = 0;
vecino = 0;
}*/
if (yo == vecino) System.out.println("EMPATE " + yo);
else if (yo < vecino) System.out.println("YO " + yo);
else System.out.println("VECINO " + vecino);
}
}
}