zoukankan      html  css  js  c++  java
  • 爱喝「肥宅快乐水」的班长

    爱喝「肥宅快乐水」的班长

    太菜了==,签到题看半天不会===

    可以用插板法

    写了个dp

    一共需要买 $n$ 瓶饮料。而在云闪付在线商城上,一共有 $m$ 种不同的饮料(包括「肥宅快乐水」,并假设云闪付在线商城上的每种饮料的购买数量都没有限制)。由于码队的弟弟喜欢喝「肥宅快乐水」,所以这两名同学决定至少要买一瓶「肥宅快乐水」。

    这样看来,饮料购买的方案实在是太多了!两位同学突发奇想,想让你帮忙计算:总共有多少种购买饮料的方案。(答案对 $10^9 + 7$ 取模,同种饮料都是一样的,不作区分。)

    #include<bits/stdc++.h>
    typedef long long ll;
    #define P pair<ll,ll>
    #define sc(x) scanf("%lld",&x);
    using namespace std;
    #define endl '
    '
    #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]<<'
    ';
        }
    }
  • 相关阅读:
    Path类
    C#集合
    阿里巴巴2013年实习生笔试题B
    阿里巴巴2013年实习生笔试题A
    腾讯2014年校园招聘笔试试题
    腾讯技术类校园招聘笔试试题
    腾讯2013年实习生笔试题
    腾讯2012年实习生笔试题
    hdu1505
    hdu1506
  • 原文地址:https://www.cnblogs.com/liulex/p/11333057.html
Copyright © 2011-2022 走看看