Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstring>
- #include <fstream>
- using namespace std;
- int r, x, n, b;
- long long dp[55][55][15];
- const long long MOD = 1e9 + 7;
- long long rec(int r1, int x1, int b1){
- if(b1==1){
- if(r1*x1>=b){
- return 1;
- }
- return 0;
- }
- if(dp[x1][r1][b1]!=-1){
- return dp[x1][r1][b1];
- }
- long long result=0;
- for(int i=1; i<r1; i++){
- if(i*x1>=b){
- result+=rec(r1-i, x1, b1-1)*2;
- result %= MOD;
- }
- }
- for(int j=1; j<x1; j++){
- if(j*r1>=b){
- result+=rec(r1, x1-j, b1-1)*2;
- result %= MOD;
- }
- }
- return dp[x1][r1][b1]=result;
- }
- int main()
- {
- // ifstream cin("input.txt");
- int t=0;
- cin>>t;
- for(int i=0; i<t; i++){
- cin>>r>>x>>b>>n;
- memset(dp, -1, sizeof dp);
- cout<<rec(r, x, n)<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement