-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTennis_UVa-12643.java
More file actions
55 lines (55 loc) · 1023 Bytes
/
Tennis_UVa-12643.java
File metadata and controls
55 lines (55 loc) · 1023 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
51
52
53
54
55
import java.util.Scanner;
/**
* UVA 12643 - Tennis Rounds
* @author Juancholasso
*
*/
class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n =0;
int i =0;
int j =0;
while(sc.hasNextInt()){
n = sc.nextInt();
i = sc.nextInt();
j = sc.nextInt();
int round = 1;
int[] lista = new int[(int) Math.pow(2,n)];
int[] lista2 = new int[lista.length/2];
if(i>j){
int temp = j;
j = i;
i = temp;
}
for(int k = 1; k<=lista.length; ++k){
lista[k-1]=k;
}
z:
while(true){
for (int k = 0; k < lista.length-1; k=k+2) {
int p1 = lista[k];
int p2 = lista[k+1];
if(p1 == i && p2 == j){
break z;
}
else{
if(p1 == i || p1 == j){
lista2[k/2]=p1;
}
else if(p2 == i || p2 == j){
lista2[k/2]=p2;
}
else{
lista2[k/2]=p1;;
}
}
}
lista = lista2;
lista2 = new int[lista.length/2];
round++;
}
System.out.println(round);
}
}
}