공부/Algorithm

백준 알고리즘[DP] - 2xn 타일링

Egomi 2017. 8. 22. 19:57

https://www.acmicpc.net/problem/11726


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import java.util.Scanner;
import java.io.FileNotFoundException;
 
class Main {
 
    public static void main(String args[]) throws FileNotFoundException{
        //FileInputStream fi = new FileInputStream("C:\\Users\\SeonMi\\Desktop\\JavaTools\\Tools\\workspace\\Solution\\src\\input.txt");
        //Scanner sc = new Scanner(fi);
        Scanner sc = new  Scanner(System.in);
        
        int n = sc.nextInt();
        long[] dp = new long[1000];
        dp[0]=1;
        dp[1]=2;
        for(int i=2;i<n;i++)
                dp[i] = (dp[i-1]+dp[i-2])%10007;
            
            System.out.println(dp[n-1]);
    }
}
cs