Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- #include <cstdio>
- #define ll long long
- #define mp make_pair
- using namespace std;
- ll N,H,M;
- ll dp[11][2501][61][71];
- ll sum[71][71]={0};
- /* ll solve(ll ini,ll h,ll top){
- //each step there are two options --> top +- 1
- if (h>H || top<=0 || ini>N)
- return (dp[ini][h][top]=0);
- else if (h<=H && top>0 && ini<=N)
- return (dp[ini][h][top] = 1);
- else
- } */
- void solve1(){
- for (int i1=1;i1<=10;i1++)
- for (int i=0;i<2500;i++)
- for (int j=0;j<61;j++)
- for (int k=0;k<71;k++)
- dp[i1][i][j][k] = 0LL;
- //dp[i][j][k]--> total of i blocks of height j and top block being k
- //can keep track of number of blocks using outside variable
- ll lim = 2500;
- for (int i1=1;i1<=10;i1++){
- dp[i1][i1][1][i1] = 1;
- for (int i=1; i <= lim ; i++){
- for (int j=2; j <= 60 ; j++){
- for (int k = 1 ; k < 71 ; k++){
- if ( (i >= k) && (k+1<70) )
- dp[i1][i][j][k] += dp[i1][i-k][j-1][k+1];
- if ( (i >= k) && (k-1>=0) )
- dp[i1][i][j][k] += dp[i1][i-k][j-1][k-1];
- //cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<"\n";
- }
- }
- }
- }
- //dp[m][h]
- for (int i = 1; i <= 10 ; i++){
- for (int j=1 ; j <= 60 ; j++){
- for (int i1=1; i1 <= 2500 ; i1++)
- for (int j1= 1 ; j1<71 ; j1++)
- sum[i][j] += dp[i][i1][j][i];
- }
- }
- }
- int main(){
- //make a tower out of n cubes such that height is h and bottom has m cubes
- //thoughts- dp, think of a recurrence
- ll t;
- scanf("%lld",&t);
- solve1();
- while(t--){
- scanf("%lld %lld %lld",&N,&H,&M);
- ll ans;
- ans = sum[M][H];
- /* ll lim = min(N,(ll)2500);
- for (int i= M ; i <= lim ; i++)
- for (int j = 1; j < 71 ; j++)
- ans = ans + dp[M][i][H][j]; */
- printf("%lld\n",ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement