Guest User

Untitled

a guest
Dec 27th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.32 KB | None | 0 0
  1. #include<iostream>
  2. using namespace std;
  3.  
  4. int ways(int n, int m){
  5.     if(n <= 0 || m <= 0)
  6.         return 0;
  7.     if(n < m)
  8.      return 1;
  9.      if(n== m)
  10.         return 2;
  11.     return ways(n-1,m) + ways(n-m, m);
  12.        
  13.  
  14.  
  15. }
  16.  
  17. int main() {
  18.     int t;
  19.     cin>>t;
  20.     while(t--){
  21.         int n, m;
  22.         cin>>n>>m;
  23.         cout<<ways(n, m)<<endl;
  24.     }
  25.     return 0;
  26. }
Add Comment
Please, Sign In to add comment