結果

問題 No.520 プロジェクトオイラーへの招待
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-05-30 11:37:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 339 ms / 4,000 ms
コード長 2,193 bytes
コンパイル時間 1,497 ms
コンパイル使用メモリ 167,940 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-21 17:59:56
合計ジャッジ時間 2,545 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
//---------------------------------------------------------------------------------------------------
int mod = 1000000007;
int add(int x, int y) { return (x += y) >= mod ? x - mod : x; }
template<class... T> int add(int x, T... y) { return add(x, add(y...)); }
int mul(int x, int y) { return 1LL * x * y % mod; }
template<class... T> int mul(int x, T... y) { return mul(x, mul(y...)); }
int sub(int x, int y) { return add(x, mod - y); }
int modpow(int a, long long b) { int ret = 1; while (b > 0) { 
if (b & 1) ret = 1LL * ret * a % mod; a = 1LL * a * a % mod; b >>= 1; } return ret; }
int modinv(int a) { return modpow(a, mod - 2); }
/*---------------------------------------------------------------------------------------------------
            ∧_∧  
      ∧_∧  (´<_` )  Welcome to My Coding Space!
     ( ´_ゝ`) /  ⌒i     
    /   \     | |     
    /   / ̄ ̄ ̄ ̄/  |  
  __(__ニつ/     _/ .| .|____  
     \/____/ (u ⊃  
---------------------------------------------------------------------------------------------------*/





int memo[201][201];
int f(int a, int b) {
    assert(0 < a);
    assert(0 < b);
    if (a == 1 || b == 1) return 1;
    if (0 <= memo[a][b]) return memo[a][b];
    return memo[a][b] = add(f(a, b - 1), f(a - 1, b));
}
//---------------------------------------------------------------------------------------------------
void _main() {
    rep(a, 0, 201) rep(b, 0, 201) memo[a][b] = -1;

    int Q; cin >> Q;
    rep(q, 0, Q) {
        int a, b, c;
        cin >> a >> b >> c;

        int ans = 0;

        ans = add(ans, f(a, b + c + 1));
        ans = add(ans, f(b, a + c + 1));
        ans = add(ans, f(c, a + b + 1));

        rep(aa, 0, a) rep(bb, 0, b) rep(cc, 0, c) {
            int d = mul(f(aa + 1, c - cc), f(bb + 1, a - aa), f(cc + 1, b - bb));
            ans = add(ans, d);
        }
        printf("%d\n", ans);
    }
}
0