Drink "happy fat house water 'squad

Drink "happy fat house water 'squad

Too dishes == === attendance problem will not see for a long time

You can use the card method

He wrote a dp

Need to buy a total of $ the n-$  bottle of drink. And in the cloud lightning pay online store, a total of $ m $  different beverages (including "fat home happy water", and assuming cloud lightning pay to purchase the quantity of each beverage on the online store without restrictions). Since the code team's younger brother likes to drink "fat home happy water", so that at least two students decided to buy a bottle of "happy fat house water."

It would appear that the beverage purchase program is too much! Two students whim, want to help you calculate: There are many kinds of schemes to buy drinks. (The answer to $ 10 $ ^ 7 + 9  modulo isoforms are the same beverage, without distinction.)

#include<bits/stdc++.h>
typedef long long ll;
#define P pair<ll,ll>
#define sc(x) scanf("%lld",&x);
using namespace std;
#define endl '\n'
#define read(A) for(int i=0;i<n;i++) scanf("%lld",&A[i]);
#define maxn 100005
int N,T;
const ll mod=1e9+7;
ll dp[1005][1005];
ll pre[1005];
void init()
{
    for(int i=1; i<=1000; i++)
        dp[i][1]=1,pre[i]=(pre[i-1]+dp[i][1])%mod;
    for(int j=2;j<=1000;j++){
        for(int i=1;i<=1000;i++){
            dp[i][j]=pre[i];
            pre[i]=(pre[i-1]+dp[i][j])%mod;
        }
    }
}

int main()
{
    init();
    sc(T);

    ll n,m;
    while(T--){
        sc(n);sc(m);
        cout<<dp[n][m]<<'\n';
    }
}

 

Guess you like

Origin www.cnblogs.com/liulex/p/11333057.html