# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
89344 | jasony123123 | Poklon (COCI17_poklon7) | Java | 1159 ms | 177980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
import java.util.*;
import java.io.*;
import java.math.*;
class poklon {
static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer token;
static int N;
static int[][] C;
static BigInteger two = new BigInteger("2");
public static void main(String[] args) throws IOException {
nextLn();
N = nextInt();
C = new int[N+1][2];
for(int i = 1; i<=N; i++) {
nextLn();
C[i][0] = nextInt();
C[i][1] = nextInt();
}
BigInteger ans = dfs(1);
System.out.println(ans.toString(2));
// System.out.println(ans);
}
public static BigInteger dfs(int x) {
if(x<0) {
return new BigInteger(Integer.toString(-x));
}
BigInteger l = dfs(C[x][0]), r = dfs(C[x][1]);
BigInteger ans;
if(l.compareTo(r)>0)
ans = l;
else
ans = r;
return ans.multiply(two);
}
//nextLn moves the token to the nextLine
public static void nextLn() throws IOException {
token = new StringTokenizer(reader.readLine());
}
//nextInt returns the next available integer
public static int nextInt() {
return Integer.parseInt(token.nextToken());
}
//nextDouble returns the next available integer
public static double nextDouble() {
return Double.parseDouble(token.nextToken());
}
//next returns the next word separated by spaces
public static String next() {
return token.nextToken();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |