Guest User

Untitled

a guest
Mar 17th, 2018
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. static int[] d = new int[10001];
  5.  
  6. static int func(int n) {
  7. d[0] = 1;
  8. d[1] = 1;
  9. if (d[n] > 0) {
  10. return d[n];
  11. }
  12. if (n >= 2) {
  13. d[n] = (func(n - 1) + func(n - 2));
  14. d[n] %= 10007;
  15. }
  16. return d[n];
  17. }
  18.  
  19. public static void main(String[] args){
  20. Scanner sc = new Scanner(System.in);
  21. int num = sc.nextInt();
  22. System.out.println(func(num));
  23. sc.close();
  24. }
  25. }
Add Comment
Please, Sign In to add comment