結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー 👑 kmjpkmjp
提出日時 2016-07-08 22:24:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,380 bytes
コンパイル時間 1,215 ms
コンパイル使用メモリ 162,096 KB
実行使用メモリ 30,620 KB
最終ジャッジ日時 2024-04-21 05:49:40
合計ジャッジ時間 9,976 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
26,752 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 56 ms
26,732 KB
testcase_03 WA -
testcase_04 AC 57 ms
26,812 KB
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 1 ms
5,376 KB
testcase_09 AC 57 ms
27,112 KB
testcase_10 AC 56 ms
26,984 KB
testcase_11 AC 60 ms
27,228 KB
testcase_12 AC 58 ms
26,992 KB
testcase_13 AC 71 ms
28,000 KB
testcase_14 AC 60 ms
27,088 KB
testcase_15 AC 57 ms
27,004 KB
testcase_16 AC 57 ms
26,988 KB
testcase_17 AC 59 ms
27,016 KB
testcase_18 AC 75 ms
29,028 KB
testcase_19 AC 56 ms
26,748 KB
testcase_20 AC 56 ms
26,752 KB
testcase_21 AC 56 ms
26,752 KB
testcase_22 AC 56 ms
26,752 KB
testcase_23 AC 57 ms
26,752 KB
testcase_24 AC 57 ms
26,752 KB
testcase_25 AC 56 ms
26,752 KB
testcase_26 AC 60 ms
26,788 KB
testcase_27 AC 57 ms
26,624 KB
testcase_28 AC 58 ms
26,624 KB
testcase_29 AC 59 ms
26,624 KB
testcase_30 AC 58 ms
26,772 KB
testcase_31 AC 55 ms
26,616 KB
testcase_32 AC 55 ms
26,752 KB
testcase_33 AC 55 ms
26,752 KB
testcase_34 AC 54 ms
26,752 KB
testcase_35 AC 54 ms
26,624 KB
testcase_36 AC 57 ms
26,752 KB
testcase_37 AC 57 ms
26,752 KB
testcase_38 AC 57 ms
26,752 KB
testcase_39 AC 55 ms
26,752 KB
testcase_40 AC 58 ms
26,828 KB
testcase_41 AC 57 ms
26,752 KB
testcase_42 AC 57 ms
26,752 KB
testcase_43 AC 56 ms
26,752 KB
testcase_44 AC 57 ms
26,744 KB
testcase_45 AC 56 ms
26,860 KB
testcase_46 AC 56 ms
26,752 KB
testcase_47 AC 53 ms
26,752 KB
testcase_48 AC 53 ms
26,752 KB
testcase_49 WA -
testcase_50 WA -
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 WA -
testcase_55 WA -
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 WA -
testcase_67 WA -
testcase_68 WA -
testcase_69 AC 63 ms
26,752 KB
testcase_70 AC 56 ms
26,624 KB
testcase_71 AC 56 ms
26,752 KB
testcase_72 AC 55 ms
26,624 KB
testcase_73 AC 55 ms
26,736 KB
testcase_74 AC 53 ms
26,752 KB
testcase_75 AC 56 ms
26,752 KB
testcase_76 AC 56 ms
26,752 KB
testcase_77 AC 57 ms
26,740 KB
testcase_78 AC 59 ms
26,652 KB
testcase_79 AC 59 ms
26,624 KB
testcase_80 AC 56 ms
26,752 KB
testcase_81 AC 55 ms
26,760 KB
testcase_82 AC 55 ms
26,752 KB
testcase_83 AC 58 ms
26,752 KB
testcase_84 AC 57 ms
26,800 KB
testcase_85 AC 56 ms
26,756 KB
testcase_86 AC 58 ms
26,752 KB
testcase_87 AC 57 ms
26,752 KB
testcase_88 AC 59 ms
26,752 KB
testcase_89 AC 67 ms
27,528 KB
testcase_90 AC 70 ms
28,136 KB
testcase_91 AC 81 ms
29,284 KB
testcase_92 AC 62 ms
26,988 KB
testcase_93 AC 72 ms
28,256 KB
testcase_94 AC 58 ms
26,880 KB
testcase_95 AC 72 ms
28,296 KB
testcase_96 AC 65 ms
27,872 KB
testcase_97 AC 64 ms
28,008 KB
testcase_98 AC 59 ms
27,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

ll mo=1000000007;
ll combi(ll N_, ll C_) {
	const int NUM_=1000001;
	static ll fact[NUM_+1],factr[NUM_+1],inv[NUM_+1];
	if (fact[0]==0) {
		inv[1]=fact[0]=factr[0]=1;
		for (int i=2;i<=NUM_;++i) inv[i] = inv[mo % i] * (mo - mo / i) % mo;
		for (int i=1;i<=NUM_;++i) fact[i]=fact[i-1]*i%mo, factr[i]=factr[i-1]*inv[i]%mo;
	}
	if(C_<0 || C_>N_) return 0;
	return factr[C_]*fact[N_]%mo*factr[N_-C_]%mo;
}
ll hcomb(int P_,int Q_) { return (P_==0&&Q_==0)?1:combi(P_+Q_-1,Q_);}

int M;
vector<ll> H;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>M;
	ll left=M;
	while(cin>>x) H.push_back(x), left-=x;
	
	if(left==M) return _P("1\n");
	
	left-=H.size()-1;
	int pat=H.size()+1;
	
	cout<<hcomb(pat,left)<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}
0