Dev.baelanche

[백준 9625] BABBA 본문

Data Structure & Algorithm/PS - JAVA

[백준 9625] BABBA

baelanche 2019. 7. 2. 23:29
반응형

 

문제에서 주어진대로 스왑해준다.

길이가 매우 길어질 수 있는 관계로 문자열 가지고 직접 구현할수는 없다.

 

public class Main {
    
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int k = sc.nextInt();
        int a = 1;
        int b = 0;
        
        while(k-->0) {
            int tempB = a;
            a -= a;
            a += b;
            b += tempB;
        }
        
        System.out.println(a + " " + b);
    }
}
반응형
Comments