結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー treeonetreeone
提出日時 2016-07-09 19:59:49
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 966 bytes
コンパイル時間 2,692 ms
コンパイル使用メモリ 161,088 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 10:55:16
合計ジャッジ時間 6,527 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 4 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 WA -
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 WA -
testcase_10 AC 9 ms
5,376 KB
testcase_11 WA -
testcase_12 AC 8 ms
5,376 KB
testcase_13 AC 29 ms
5,376 KB
testcase_14 AC 12 ms
5,376 KB
testcase_15 AC 7 ms
5,376 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 5 ms
5,376 KB
testcase_20 AC 5 ms
5,376 KB
testcase_21 AC 5 ms
5,376 KB
testcase_22 AC 5 ms
5,376 KB
testcase_23 AC 4 ms
5,376 KB
testcase_24 AC 4 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 5 ms
5,376 KB
testcase_27 AC 4 ms
5,376 KB
testcase_28 AC 5 ms
5,376 KB
testcase_29 AC 4 ms
5,376 KB
testcase_30 AC 5 ms
5,376 KB
testcase_31 AC 5 ms
5,376 KB
testcase_32 AC 5 ms
5,376 KB
testcase_33 AC 4 ms
5,376 KB
testcase_34 AC 4 ms
5,376 KB
testcase_35 AC 5 ms
5,376 KB
testcase_36 AC 4 ms
5,376 KB
testcase_37 AC 5 ms
5,376 KB
testcase_38 AC 5 ms
5,376 KB
testcase_39 AC 5 ms
5,376 KB
testcase_40 AC 5 ms
5,376 KB
testcase_41 AC 5 ms
5,376 KB
testcase_42 AC 4 ms
5,376 KB
testcase_43 AC 5 ms
5,376 KB
testcase_44 AC 5 ms
5,376 KB
testcase_45 AC 5 ms
5,376 KB
testcase_46 AC 5 ms
5,376 KB
testcase_47 AC 5 ms
5,376 KB
testcase_48 AC 5 ms
5,376 KB
testcase_49 AC 51 ms
5,376 KB
testcase_50 AC 5 ms
5,376 KB
testcase_51 AC 4 ms
5,376 KB
testcase_52 AC 11 ms
5,376 KB
testcase_53 AC 6 ms
5,376 KB
testcase_54 AC 13 ms
5,376 KB
testcase_55 AC 2 ms
5,376 KB
testcase_56 AC 6 ms
5,376 KB
testcase_57 AC 23 ms
5,376 KB
testcase_58 AC 42 ms
5,376 KB
testcase_59 AC 32 ms
5,376 KB
testcase_60 AC 15 ms
5,376 KB
testcase_61 AC 67 ms
5,376 KB
testcase_62 AC 16 ms
5,376 KB
testcase_63 AC 43 ms
5,376 KB
testcase_64 AC 13 ms
5,376 KB
testcase_65 AC 8 ms
5,376 KB
testcase_66 AC 14 ms
5,376 KB
testcase_67 AC 14 ms
5,376 KB
testcase_68 AC 14 ms
5,376 KB
testcase_69 WA -
testcase_70 AC 4 ms
5,376 KB
testcase_71 WA -
testcase_72 AC 5 ms
5,376 KB
testcase_73 AC 5 ms
5,376 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 4 ms
5,376 KB
testcase_77 WA -
testcase_78 AC 5 ms
5,376 KB
testcase_79 AC 5 ms
5,376 KB
testcase_80 AC 4 ms
5,376 KB
testcase_81 AC 5 ms
5,376 KB
testcase_82 AC 4 ms
5,376 KB
testcase_83 AC 5 ms
5,376 KB
testcase_84 AC 5 ms
5,376 KB
testcase_85 AC 5 ms
5,376 KB
testcase_86 AC 4 ms
5,376 KB
testcase_87 AC 5 ms
5,376 KB
testcase_88 AC 5 ms
5,376 KB
testcase_89 AC 21 ms
5,376 KB
testcase_90 AC 31 ms
5,376 KB
testcase_91 WA -
testcase_92 AC 11 ms
5,376 KB
testcase_93 AC 34 ms
5,376 KB
testcase_94 AC 5 ms
5,376 KB
testcase_95 WA -
testcase_96 AC 28 ms
5,376 KB
testcase_97 AC 27 ms
5,376 KB
testcase_98 AC 16 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repp(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
int n;

typedef long long ll;
ll mod_pow(ll x,ll n){
	if(n==0) return 1;
	ll res=mod_pow(x*x%mod,n/2);
	if(n&1) res=res*x%mod;
	return res;
}
ll fact[2000010];
ll get_nCk(ll n,ll k,ll mpd){
	fact[0]=1;
	for(int i=1;i<200010;i++) fact[i]=fact[i-1]*i%mod;
	return fact[n]*mod_pow(fact[k],mod-2)%mod*mod_pow(fact[n-k],mod-2)%mod;
}

signed main(){
    cin >> n;
    vector<int> h;
    int a, sum = 0, cnt = 0;
    while(cin >> a){
        sum += a;
        cnt++;
    }
    int ans = 0;
    int r = n - (sum + cnt - 1);
    if(sum == 0) cout << 1 << endl;
    else if(r < 0) cout << "NA" << endl;
    else{
        ans = get_nCk(r + cnt, cnt, mod);
        cout << ans << endl;
    }
}
0