結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー sekiya9311sekiya9311
提出日時 2016-07-09 00:15:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,950 bytes
コンパイル時間 1,111 ms
コンパイル使用メモリ 108,348 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-21 08:55:03
合計ジャッジ時間 3,763 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define VI vector<int>
#define VL vector<long>
#define VD vector<double>
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define REVERSE(a) reverse(ALL(a))
#define MP make_pair
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

#define long LL
long pow_mod(long a,long p){
    if(p==0) return 1;
    if(p&1) return a*pow_mod(a,p-1)%MOD;
    long t=pow_mod(a,p/2)%MOD;
    return t*t%MOD;
}

int main(void){
    int M; cin>>M; vector<int> v;
    int in; while(cin>>in){
        if(in==0) break;
        v.emplace_back(in);
    }
    int sum=accumulate(ALL(v),0);
    if(v.size()==1 && v.front()==0){
        cout<<1<<endl; return 0;
    }
    if(v.size()==1 && v[0]==M){
        cout<<1<<endl; return 0;
    }
    if(M-sum<v.size()-1){
        cout<<"NA"<<endl; return 0;
    }
    long ans=1;
    REP(i,v.size()){
        if(i==0 || i==v.size()-1) ans*=(M-sum+1);
        else ans*=(M-sum);
        ans%=MOD;
    }
    long buf=pow_mod(v.size()+1,MOD-2);
    cout<<ans*buf%MOD<<endl;
    return 0;
}
0