結果

問題 No.520 プロジェクトオイラーへの招待
ユーザー chocoruskchocorusk
提出日時 2020-01-21 21:39:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 138 ms / 4,000 ms
コード長 1,790 bytes
コンパイル時間 999 ms
コンパイル使用メモリ 112,216 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 10:52:47
合計ジャッジ時間 1,767 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 43 ms
4,380 KB
testcase_04 AC 47 ms
4,380 KB
testcase_05 AC 138 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
ll powmod(ll a, ll k){
    ll ap=a, ans=1;
    while(k){
        if(k&1){
            ans*=ap;
            ans%=MOD;
        }
        ap=ap*ap;
        ap%=MOD;
        k>>=1;
    }
    return ans;
}
ll inv(ll a){
    return powmod(a, MOD-2);
}
ll f[220], invf[220];
void fac(int n){
    f[0]=1;
    for(ll i=1; i<=n; i++) f[i]=f[i-1]*i%MOD;
    invf[n]=inv(f[n]);
    for(ll i=n-1; i>=0; i--) invf[i]=invf[i+1]*(i+1)%MOD;
}
ll comb(int x, int y){
    if(!(0<=y && y<=x)) return 0;
    return f[x]*invf[y]%MOD*invf[x-y]%MOD;
}
int main()
{
	fac(210);
	int n;
	cin>>n;
	for(int z=0; z<n; z++){
		int a, b, c;
		cin>>a>>b>>c;
		ll ans=0;
		for(int i=0; i<a; i++){
			for(int j=0; j<b; j++){
				for(int k=0; k<c; k++){
					(ans+=comb(i+c-1-k, i)*comb(j+a-1-i, j)%MOD*comb(k+b-1-j, k))%=MOD;
				}
			}
		}
		for(int i=0; i<a; i++){
          for(int j=i; j<a; j++){
			(ans+=comb(i+c-1, c-1)*comb(a-1-j+b-1, b-1))%=MOD;
          }
		}
		for(int i=0; i<b; i++){
          for(int j=i; j<b; j++){
			(ans+=comb(i+a-1, a-1)*comb(b-1-j+c-1, c-1))%=MOD;
          }
		}
		for(int i=0; i<c; i++){
          for(int j=i; j<c; j++){
			(ans+=comb(i+b-1, b-1)*comb(c-1-j+a-1, a-1))%=MOD;
          }
		}
		cout<<ans<<endl;
	}
	return 0;
}
0