結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー n_vipn_vip
提出日時 2016-07-08 22:40:46
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,393 bytes
コンパイル時間 827 ms
コンパイル使用メモリ 98,808 KB
実行使用メモリ 10,456 KB
最終ジャッジ日時 2024-04-21 07:21:49
合計ジャッジ時間 4,864 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 12 ms
8,064 KB
testcase_01 WA -
testcase_02 AC 12 ms
8,192 KB
testcase_03 AC 13 ms
8,064 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 14 ms
8,448 KB
testcase_11 WA -
testcase_12 AC 14 ms
8,320 KB
testcase_13 AC 25 ms
9,176 KB
testcase_14 AC 17 ms
8,448 KB
testcase_15 AC 14 ms
8,320 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 13 ms
7,936 KB
testcase_20 AC 12 ms
8,192 KB
testcase_21 AC 13 ms
8,192 KB
testcase_22 AC 13 ms
8,064 KB
testcase_23 AC 12 ms
8,064 KB
testcase_24 AC 12 ms
8,064 KB
testcase_25 AC 12 ms
8,064 KB
testcase_26 AC 13 ms
8,064 KB
testcase_27 AC 12 ms
8,064 KB
testcase_28 AC 13 ms
8,064 KB
testcase_29 AC 13 ms
8,064 KB
testcase_30 AC 12 ms
8,064 KB
testcase_31 AC 12 ms
8,064 KB
testcase_32 AC 12 ms
8,064 KB
testcase_33 AC 12 ms
8,192 KB
testcase_34 AC 13 ms
7,936 KB
testcase_35 AC 13 ms
8,064 KB
testcase_36 AC 13 ms
8,192 KB
testcase_37 AC 13 ms
8,192 KB
testcase_38 AC 12 ms
8,064 KB
testcase_39 AC 12 ms
7,936 KB
testcase_40 AC 13 ms
8,064 KB
testcase_41 AC 13 ms
8,192 KB
testcase_42 AC 12 ms
8,064 KB
testcase_43 AC 13 ms
8,064 KB
testcase_44 AC 13 ms
8,064 KB
testcase_45 AC 12 ms
8,192 KB
testcase_46 AC 13 ms
8,192 KB
testcase_47 AC 13 ms
8,064 KB
testcase_48 AC 13 ms
8,064 KB
testcase_49 AC 38 ms
10,456 KB
testcase_50 AC 14 ms
8,192 KB
testcase_51 AC 13 ms
8,320 KB
testcase_52 AC 17 ms
8,448 KB
testcase_53 AC 14 ms
8,320 KB
testcase_54 AC 18 ms
8,576 KB
testcase_55 AC 13 ms
8,192 KB
testcase_56 AC 14 ms
8,448 KB
testcase_57 AC 24 ms
9,304 KB
testcase_58 AC 33 ms
10,276 KB
testcase_59 AC 28 ms
9,308 KB
testcase_60 AC 20 ms
8,832 KB
testcase_61 AC 45 ms
10,328 KB
testcase_62 AC 20 ms
8,704 KB
testcase_63 AC 34 ms
10,324 KB
testcase_64 AC 17 ms
8,448 KB
testcase_65 AC 15 ms
8,448 KB
testcase_66 AC 19 ms
8,704 KB
testcase_67 AC 18 ms
8,576 KB
testcase_68 AC 18 ms
8,576 KB
testcase_69 WA -
testcase_70 AC 13 ms
8,064 KB
testcase_71 WA -
testcase_72 AC 12 ms
8,192 KB
testcase_73 AC 13 ms
8,064 KB
testcase_74 WA -
testcase_75 WA -
testcase_76 AC 12 ms
8,192 KB
testcase_77 WA -
testcase_78 AC 13 ms
8,064 KB
testcase_79 AC 12 ms
8,064 KB
testcase_80 AC 13 ms
8,192 KB
testcase_81 AC 13 ms
8,064 KB
testcase_82 AC 14 ms
8,064 KB
testcase_83 AC 13 ms
8,064 KB
testcase_84 AC 13 ms
8,064 KB
testcase_85 AC 13 ms
8,192 KB
testcase_86 AC 13 ms
8,064 KB
testcase_87 AC 13 ms
8,064 KB
testcase_88 AC 12 ms
8,192 KB
testcase_89 AC 21 ms
8,704 KB
testcase_90 AC 26 ms
9,428 KB
testcase_91 WA -
testcase_92 AC 16 ms
8,448 KB
testcase_93 AC 27 ms
9,304 KB
testcase_94 AC 13 ms
7,936 KB
testcase_95 AC 28 ms
9,304 KB
testcase_96 AC 25 ms
9,432 KB
testcase_97 AC 24 ms
9,300 KB
testcase_98 AC 18 ms
8,704 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
vector<ll> fact,finv,inv;
ll comb(ll n,ll r){
  if(n<r||r<0)return 0;
  return fact[n]*finv[n-r]%MOD*finv[r]%MOD;
}
class Doralion{
  void Modinvs(vector<ll> &re,int n){
    re.resize(n+1); re[1]=1;
    for(int i=2;i<=n;++i)re[i]=re[MOD%i]*(MOD-MOD/i)%MOD;
  }
  void Facts(vector<ll> &re,int n){
    re.resize(n+1); re[0]=1;
    rep(i,n)re[i+1]=re[i]*(i+1)%MOD;
  }
  void Factinvs(vector<ll> &re,const vector<ll> &inv,int n){
    re.resize(n+1); re[0]=1;
    rep(i,n)re[i+1]=re[i]*inv[i+1]%MOD;
  }
public:
  Doralion(int n){
    Modinvs(inv,n);
    Facts(fact,n);
    Factinvs(finv,inv,n);
  }
} doralion(212345);

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int m;
  cin>>m;
  vector<int> a;
  int x;
  while(cin>>x) a.pb(x);
  if(a[0]==0){
    cout<<0<<endl;
    return 0;
  }
  int n=a.size();
  int s=accumulate(all(a),-n);
  m-=s;
  if(m<n*2-1){
    cout<<"NA"<<endl;
    return 0;
  }
  cout<<comb(m-n+1,n)<<endl;
  return 0;
}
0