結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー latte0119latte0119
提出日時 2016-07-08 22:35:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 1,365 bytes
コンパイル時間 1,155 ms
コンパイル使用メモリ 147,760 KB
実行使用メモリ 43,280 KB
最終ジャッジ日時 2023-08-03 06:59:54
合計ジャッジ時間 8,463 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
38,160 KB
testcase_01 AC 39 ms
38,212 KB
testcase_02 AC 39 ms
38,132 KB
testcase_03 AC 39 ms
38,172 KB
testcase_04 AC 39 ms
38,156 KB
testcase_05 AC 39 ms
38,132 KB
testcase_06 AC 39 ms
38,248 KB
testcase_07 AC 39 ms
38,132 KB
testcase_08 AC 39 ms
38,292 KB
testcase_09 AC 42 ms
38,468 KB
testcase_10 AC 41 ms
38,212 KB
testcase_11 AC 44 ms
38,452 KB
testcase_12 AC 41 ms
38,516 KB
testcase_13 AC 53 ms
39,784 KB
testcase_14 AC 44 ms
38,464 KB
testcase_15 AC 41 ms
38,212 KB
testcase_16 AC 41 ms
38,324 KB
testcase_17 AC 43 ms
38,376 KB
testcase_18 AC 64 ms
42,920 KB
testcase_19 AC 39 ms
38,164 KB
testcase_20 AC 39 ms
38,112 KB
testcase_21 AC 39 ms
38,112 KB
testcase_22 AC 39 ms
38,168 KB
testcase_23 AC 39 ms
38,240 KB
testcase_24 AC 39 ms
38,252 KB
testcase_25 AC 39 ms
38,140 KB
testcase_26 AC 39 ms
38,184 KB
testcase_27 AC 39 ms
38,096 KB
testcase_28 AC 39 ms
38,140 KB
testcase_29 AC 39 ms
38,088 KB
testcase_30 AC 39 ms
38,088 KB
testcase_31 AC 39 ms
38,248 KB
testcase_32 AC 39 ms
38,252 KB
testcase_33 AC 39 ms
38,088 KB
testcase_34 AC 39 ms
38,212 KB
testcase_35 AC 39 ms
38,220 KB
testcase_36 AC 39 ms
38,248 KB
testcase_37 AC 39 ms
38,208 KB
testcase_38 AC 39 ms
38,212 KB
testcase_39 AC 39 ms
38,364 KB
testcase_40 AC 39 ms
38,248 KB
testcase_41 AC 39 ms
38,104 KB
testcase_42 AC 39 ms
38,088 KB
testcase_43 AC 39 ms
38,116 KB
testcase_44 AC 39 ms
38,128 KB
testcase_45 AC 39 ms
38,208 KB
testcase_46 AC 39 ms
38,096 KB
testcase_47 AC 39 ms
38,140 KB
testcase_48 AC 39 ms
38,144 KB
testcase_49 AC 67 ms
43,280 KB
testcase_50 AC 40 ms
38,308 KB
testcase_51 AC 40 ms
38,420 KB
testcase_52 AC 44 ms
38,392 KB
testcase_53 AC 41 ms
38,220 KB
testcase_54 AC 44 ms
38,392 KB
testcase_55 AC 40 ms
38,344 KB
testcase_56 AC 41 ms
38,280 KB
testcase_57 AC 52 ms
39,760 KB
testcase_58 AC 62 ms
43,044 KB
testcase_59 AC 56 ms
39,832 KB
testcase_60 AC 47 ms
39,040 KB
testcase_61 AC 75 ms
42,980 KB
testcase_62 AC 47 ms
38,712 KB
testcase_63 AC 63 ms
43,180 KB
testcase_64 AC 45 ms
38,392 KB
testcase_65 AC 43 ms
38,376 KB
testcase_66 AC 46 ms
38,796 KB
testcase_67 AC 46 ms
38,848 KB
testcase_68 AC 45 ms
38,836 KB
testcase_69 AC 39 ms
38,388 KB
testcase_70 AC 39 ms
38,092 KB
testcase_71 AC 39 ms
38,156 KB
testcase_72 AC 40 ms
38,168 KB
testcase_73 AC 42 ms
38,264 KB
testcase_74 AC 40 ms
38,108 KB
testcase_75 AC 39 ms
38,092 KB
testcase_76 AC 39 ms
38,116 KB
testcase_77 AC 39 ms
38,132 KB
testcase_78 AC 39 ms
38,092 KB
testcase_79 AC 40 ms
38,144 KB
testcase_80 AC 39 ms
38,168 KB
testcase_81 AC 39 ms
38,248 KB
testcase_82 AC 39 ms
38,180 KB
testcase_83 AC 39 ms
38,116 KB
testcase_84 AC 39 ms
38,132 KB
testcase_85 AC 39 ms
38,240 KB
testcase_86 AC 39 ms
38,244 KB
testcase_87 AC 39 ms
38,124 KB
testcase_88 AC 39 ms
38,244 KB
testcase_89 AC 48 ms
38,972 KB
testcase_90 AC 54 ms
39,820 KB
testcase_91 AC 66 ms
42,716 KB
testcase_92 AC 43 ms
38,400 KB
testcase_93 AC 56 ms
39,820 KB
testcase_94 AC 40 ms
38,152 KB
testcase_95 AC 56 ms
39,888 KB
testcase_96 AC 53 ms
39,844 KB
testcase_97 AC 52 ms
39,832 KB
testcase_98 AC 46 ms
38,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

#define int long long
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

const int mod=1000000007;
int fact[2222222],inv[2222222];
int mpow(int n,int m){
    int ret=1;
    while(m){
        if(m&1)ret=ret*n%mod;
        n=n*n%mod;
        m>>=1;
    }
    return ret;
}
int C(int n,int k){
    return fact[n]*inv[k]%mod*inv[n-k]%mod;
}

signed main(){
    fact[0]=1;
    for(int i=1;i<2222222;i++)fact[i]=fact[i-1]*i%mod;
    inv[2222222-1]=mpow(fact[2222222-1],mod-2);
    for(int i=2222222-2;i>=0;i--)inv[i]=inv[i+1]*(i+1)%mod;

    int M;scanf("%lld",&M);
    vint H;
    int h;
    while(scanf("%lld",&h)!=EOF)H.pb(h);

    int s=accumulate(all(H),0ll);

    if(s==0){
        cout<<1<<endl;
        return 0;
    }
    if(M-s+1<H.size()){
        cout<<"NA"<<endl;
        return 0;
    }

    int t=M-s-H.size()+1;

    cout<<C(t+H.size(),H.size())<<endl;
    return 0;
}
0