結果
| 問題 |
No.389 ロジックパズルの組み合わせ
|
| コンテスト | |
| ユーザー |
sekiya9311
|
| 提出日時 | 2016-07-12 10:00:52 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,021 bytes |
| コンパイル時間 | 969 ms |
| コンパイル使用メモリ | 106,644 KB |
| 実行使用メモリ | 5,580 KB |
| 最終ジャッジ日時 | 2024-10-14 14:14:31 |
| 合計ジャッジ時間 | 4,399 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 94 WA * 5 |
ソースコード
#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 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)
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int INF=1e9;
const int MOD=INF+7;
LL pow_mod(LL a,LL p){
if(p==0) return 1;
if(p&1) return a*pow_mod(a,p-1)%MOD;
LL t=pow_mod(a,p/2);
return t*t%MOD;
}
LL fact_mod(LL n){
LL ret=1;
for(LL i=n;i>1;i--){
ret*=i; ret%=MOD;
}
return ret;
}
LL fact_mod_inverse(LL n){
if(n==1) return 1;
LL t=fact_mod(n);
return pow_mod(t,MOD-2)%MOD;
}
int main(void){
int M; cin>>M;
vector<int> H;
int buf; long sum=0;
while(cin>>buf){
H.emplace_back(buf);
sum+=buf;
}
if(H[0]==1&&H.size()==1){
cout<<1<<endl;
return 0;
}
if(M<sum+H.size()-1){
cout<<"NA"<<endl;
return 0;
}
LL ans=fact_mod(M-sum+1);
ans*=fact_mod_inverse(M-sum+1-H.size()); ans%=MOD;
ans*=fact_mod_inverse(H.size()); ans%=MOD;
cout<<ans<<endl;
return 0;
}
sekiya9311