[백준] 11726. 2xn 타일링(실버3)(실버3)

백준(실버3) - 11726. 2xn 타일링(실버3)



풀이

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		int[] arr = new int[1001];

		arr[1] = 1;
		arr[2] = 2;
		
		if(n>=3) {
			for(int i=3; i<=n; i++)
				arr[i] = (arr[i-1]+ arr[i-2])%10007;
		}
		
		System.out.println(arr[n]);
		sc.close();
	}
}

좋은 웹페이지 즐겨찾기