import java.util.*;
public class Main {
public static void main(String args[]) {
Scanner cin = new Scanner(System.in);
int t = cin.nextInt();
while(t>0){
int n = cin.nextInt(), m= cin.nextInt();
System.out.println(noOfWays(n,m));
t–;
}
}
public static int noOfWays(int n, int m){
int count[] = new int[n+1];
count[0] = 0;
for(int i =1;i<count.length;i++){
if(i == m){
count[i] = 2;
}else if(i<m){
count[i] = 1;
}else{
count[i] = count[i-1] + count[i-m];
}
}
return count[n];
}
}================what’s the error in the code
Tilling problem question
change everything to long and take the mod of the ans by 10^9 + 7
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.