본문 바로가기
알고리즘 풀이

[백준] 2903번: 중앙 이동 알고리즘 - java 풀이

by 코디드 2023. 6. 28.

 

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main2903 {

	public static void main(String[] args) throws IOException{
		
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		int N = Integer.parseInt(br.readLine());
		br.close();
		
		int result = (int)Math.pow((Math.pow(2, N)+1), 2); 
		
		System.out.println(result);
	}
}

 

과정 수(N)    0         1          2           3   
점 개수    4(2^2)  9(3^2)  25(5^2)  81(9^2)

 

과정 수를 N이라고 할때 (2^N + 1)^2 개의 점이 생기는 규칙을 파악할 수 있다.