結果

問題 No.498 ワープクリスタル (給料日編)
ユーザー butsurizukibutsurizuki
提出日時 2017-03-25 00:00:27
言語 C90
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,173 bytes
コンパイル時間 1,014 ms
コンパイル使用メモリ 28,868 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-09-20 06:16:45
合計ジャッジ時間 2,636 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 3 ms
4,384 KB
testcase_02 AC 3 ms
4,384 KB
testcase_03 AC 2 ms
4,384 KB
testcase_04 RE -
testcase_05 AC 2 ms
4,388 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 RE -
testcase_09 AC 4 ms
4,384 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 AC 4 ms
4,380 KB
testcase_20 WA -
testcase_21 AC 4 ms
4,380 KB
testcase_22 AC 4 ms
4,380 KB
testcase_23 WA -
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#define teisu 1000000007

long long kaijo(long long x){
	long long i,r=1;
	for(i = 1;i <= x;i++){r*=i;}
	return r;
}

long long nCr(long long n,long long r){
	return kaijo(n)/(kaijo(r)*kaijo(n-r));
}

int main(void){
	long long gx,gy,k;
	long long i,x[8]={0},y[8]={0},n[8]={0};
	long long r = 0,ri;
	long long a,b,c,d,e,s;
	scanf("%lld%lld%lld",&gx,&gy,&k);
	for(i = 1;i <= k;i++){
		scanf("%lld%lld%lld",&x[i],&y[i],&n[i]);
	}
	for(a = 0;a <= 15;a++){
	for(b = 0;b <= 15;b++){
	for(c = 0;c <= 15;c++){
	for(d = 0;d <= 15;d++){
	for(e = 0;e <= 15;e++){
		if(n[1] >= a && n[2] >= b && n[3] >= c && n[4] >= d && n[5] >= e){
			if(x[1]*a+x[2]*b+x[3]*c+x[4]*d+x[5]*e == gx && y[1]*a+y[2]*b+y[3]*c+y[4]*d+y[5]*e == gy){
				if(k == 1){s = a;}
				if(k == 2){s = a+b;}
				if(k == 3){s = a+b+c;}
				if(k == 4){s = a+b+c+d;}
				if(k == 5){s = a+b+c+d+e;}
				if(k >= 1){ri = nCr(s,a)%teisu;s-=a;}
				if(k >= 2){ri*=nCr(s,b);ri%=teisu;s-=b;}
				if(k >= 3){ri*=nCr(s,c);ri%=teisu;s-=c;}
				if(k >= 4){ri*=nCr(s,d);ri%=teisu;s-=d;}
				if(k >= 5){ri*=nCr(s,e);ri%=teisu;s-=e;}
				r+=ri;
				r%=teisu;
			}
		}
	}
	}
	}
	}
	}
	printf("%lld\n",r);
	return 0;
}
0