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 |
'공부 > Algorithm' 카테고리의 다른 글
백준 알고리즘 11403 - 경로 찾기 (0) | 2017.08.28 |
---|---|
백준알고리즘 2538 - 모눈종이 자르기 (0) | 2017.08.28 |
백준 알고리즘 - 팰린드롬? (0) | 2017.08.22 |
백준 알고리즘[DP] - 이동하기 (0) | 2017.08.22 |
백준 알고리즘[DP] - 합분해 (0) | 2017.08.22 |