結果

問題 No.520 プロジェクトオイラーへの招待
ユーザー 👑 horiesinitihoriesiniti
提出日時 2017-05-12 14:22:06
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 335 ms / 4,000 ms
コード長 1,044 bytes
コンパイル時間 463 ms
コンパイル使用メモリ 62,700 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-10-13 13:54:55
合計ジャッジ時間 1,682 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 99 ms
4,352 KB
testcase_04 AC 107 ms
4,348 KB
testcase_05 AC 335 ms
4,352 KB
testcase_06 AC 2 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string.h>
#include<stdio.h>
#include<vector>

const int LIMIT=222;
long long int rf[LIMIT][LIMIT];
long long int MOD=1000000007;

long long int f(int x,int y){
	if((x==1)||(y==1)){
		return 1;
	}else{
		return (rf[x-1][y]+rf[x][y-1])%MOD;
	}
}

int main(){
	memset(rf,0,sizeof(rf));
	rf[1][1]=1;
	for(int i=2;i<LIMIT*2;i++){
		for(int j=1;j<i;j++){
			int x=i-j;
			int y=j;
			if((x>=LIMIT)||(y>=LIMIT))continue;
			rf[x][y]=f(x,y);
		}
	}
	int n;
	scanf("%d",&n);
	std::vector<long long int> anss;
	for(int i=0;i<n;i++){
		int a1,b1,c1;
		scanf("%d %d %d",&a1,&b1,&c1);
		long long int ans=0;
		ans=(ans+rf[b1][c1+a1+1])%MOD;
		ans=(ans+rf[c1][b1+a1+1])%MOD;
		ans=(ans+rf[a1][b1+c1+1])%MOD;
		for(int a2=1;a2<=a1;a2++){
			for(int b2=1;b2<=b1;b2++){
				for(int c2=1;c2<=c1;c2++){
					long long int perm=(rf[b2][c1-c2+1]*rf[b1-b2+1][a2])%MOD;
					perm=(perm*rf[a1-a2+1][c2])%MOD;
					ans=(ans+perm)%MOD;
				}
			}
		}
		anss.push_back(ans);
	}
	for(int i=0;i<anss.size();i++){
		std::cout<<anss[i]<<"\n";
	}
}
0