Advertisement
vov44k

Untitled

Sep 18th, 2022
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.58 KB | None | 0 0
  1. import java.io.*;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.  
  6.     public static void main(String[] args){
  7.         Scanner in = new Scanner(System.in);
  8.         int n = in.nextInt();
  9.         int k = in.nextInt();
  10.  
  11.         long[] fib = new long[10005];
  12.         long MOD = (long) 1e6 + 7;
  13.         fib[0] = 1;
  14.         fib[1] = 1;
  15.         for (int i = 2; i < n; i++) {
  16.             for (int j = Math.max(0, i - k); j < i; j++) {
  17.                 fib[i] = (fib[i] + fib[j]) % MOD;
  18.             }
  19.         }
  20.  
  21.         System.out.print(fib[n - 1]);
  22.  
  23.  
  24.         in.close();
  25.     }
  26.  
  27.  
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement