코딩테스트/Softeer

[Softeer]지도 자동 구축 - Java

GAEBAL 2022. 5. 20. 22:26
728x90

문제

https://softeer.ai/practice/info.do?eventIdx=1&psProblemId=413

 

Softeer

연습문제를 담을 Set을 선택해주세요. 취소 확인

softeer.ai

 

 

풀이

이 문제도 그냥 수학적 사고를 필요로 하는 문제인 것 같다.

다른 트릭? 같은건 없고

그냥 점화식을 잘 세워보던가 규칙을 찾아보던가

편하게 풀 수 있는 문제임!!

 

 

코드

// Softeer - 지도 자동 구축
// https://softeer.ai/practice/info.do?eventIdx=1&psProblemId=413

import java.io.IOException;
import java.util.Scanner;

public class Softeer_Num413_지도자동구축 {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);

        long N = sc.nextLong();

        long temp = 1;

        for (int i = 0; i < N; i++) {
            temp *= 2;
        }
        temp++;

        System.out.println(temp * temp);
    }
}
728x90