답안 #89341

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
89341 2018-12-11T22:52:20 Z jasony123123 Poklon (COCI17_poklon7) C++11
컴파일 오류
0 ms 0 KB
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;
	
	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(new BigInteger("2"));
	}

	//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();
	}
}

Compilation message

poklon.cpp:1:1: error: 'import' does not name a type; did you mean 'short'?
 import java.util.*;
 ^~~~~~
 short
poklon.cpp:2:1: error: 'import' does not name a type; did you mean 'short'?
 import java.io.*;
 ^~~~~~
 short
poklon.cpp:3:1: error: 'import' does not name a type; did you mean 'short'?
 import java.math.*;
 ^~~~~~
 short
poklon.cpp:6:9: error: 'BufferedReader' does not name a type
  static BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
         ^~~~~~~~~~~~~~
poklon.cpp:7:9: error: 'StringTokenizer' does not name a type
  static StringTokenizer token;
         ^~~~~~~~~~~~~~~
poklon.cpp:10:12: error: expected unqualified-id before '[' token
  static int[][] C;
            ^
poklon.cpp:12:9: error: expected ':' before 'static'
  public static void main(String[] args) throws IOException {
         ^~~~~~
poklon.cpp:12:26: error: 'String' has not been declared
  public static void main(String[] args) throws IOException {
                          ^~~~~~
poklon.cpp:12:35: error: expected ',' or '...' before 'args'
  public static void main(String[] args) throws IOException {
                                   ^~~~
poklon.cpp:12:39: error: expected ';' at end of member declaration
  public static void main(String[] args) throws IOException {
                                       ^
poklon.cpp:12:41: error: 'throws' does not name a type
  public static void main(String[] args) throws IOException {
                                         ^~~~~~
poklon.cpp:26:9: error: expected ':' before 'static'
  public static BigInteger dfs(int x) {
         ^~~~~~
poklon.cpp:26:16: error: 'BigInteger' does not name a type
  public static BigInteger dfs(int x) {
                ^~~~~~~~~~
poklon.cpp:40:9: error: expected ':' before 'static'
  public static void nextLn() throws IOException {
         ^~~~~~
poklon.cpp:40:28: error: expected ';' at end of member declaration
  public static void nextLn() throws IOException {
                            ^
poklon.cpp:40:30: error: 'throws' does not name a type
  public static void nextLn() throws IOException {
                              ^~~~~~
poklon.cpp:44:9: error: expected ':' before 'static'
  public static int nextInt() {
         ^~~~~~
poklon.cpp:48:9: error: expected ':' before 'static'
  public static double nextDouble() {
         ^~~~~~
poklon.cpp:52:9: error: expected ':' before 'static'
  public static String next() {
         ^~~~~~
poklon.cpp:52:16: error: 'String' does not name a type
  public static String next() {
                ^~~~~~
poklon.cpp:55:2: error: expected ';' after class definition
 }
  ^
  ;
poklon.cpp: In static member function 'static int poklon::nextInt()':
poklon.cpp:45:10: error: 'Integer' was not declared in this scope
   return Integer.parseInt(token.nextToken());
          ^~~~~~~
poklon.cpp:45:27: error: 'token' was not declared in this scope
   return Integer.parseInt(token.nextToken());
                           ^~~~~
poklon.cpp:45:27: note: suggested alternative: 'poklon'
   return Integer.parseInt(token.nextToken());
                           ^~~~~
                           poklon
poklon.cpp: In static member function 'static double poklon::nextDouble()':
poklon.cpp:49:10: error: 'Double' was not declared in this scope
   return Double.parseDouble(token.nextToken());
          ^~~~~~
poklon.cpp:49:10: note: suggested alternative: 'double'
   return Double.parseDouble(token.nextToken());
          ^~~~~~
          double
poklon.cpp:49:29: error: 'token' was not declared in this scope
   return Double.parseDouble(token.nextToken());
                             ^~~~~
poklon.cpp:49:29: note: suggested alternative: 'poklon'
   return Double.parseDouble(token.nextToken());
                             ^~~~~
                             poklon