Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static int[] d = new int[10001];
- static int func(int n) {
- d[0] = 1;
- d[1] = 1;
- if (d[n] > 0) {
- return d[n];
- }
- if (n >= 2) {
- d[n] = (func(n - 1) + func(n - 2));
- d[n] %= 10007;
- }
- return d[n];
- }
- public static void main(String[] args){
- Scanner sc = new Scanner(System.in);
- int num = sc.nextInt();
- System.out.println(func(num));
- sc.close();
- }
- }
Add Comment
Please, Sign In to add comment