Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args){
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- int k = in.nextInt();
- int l = in.nextInt();
- boolean[] frog = new boolean[n];
- for (int i = 0; i < l; i++) {
- frog[in.nextInt() - 1] = true;
- }
- int[] Arr = new int[100000];
- Arr[0] = 1;
- if (!frog[1])
- Arr[1] = 1;
- for (int i = 2; i < n; i++) {
- if (!frog[i]) {
- for (int j = Math.max(0, i - k); j < i; j++) {
- Arr[i] += Arr[j];
- }
- }
- }
- System.out.println(Arr[n - 1]);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment