結果

問題 No.520 プロジェクトオイラーへの招待
ユーザー parukiparuki
提出日時 2017-06-06 11:01:25
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 4,000 ms
コード長 2,083 bytes
コンパイル時間 2,837 ms
コンパイル使用メモリ 169,272 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-23 17:47:16
合計ジャッジ時間 2,668 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 13 ms
4,348 KB
testcase_04 AC 15 ms
4,348 KB
testcase_05 AC 41 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i))
#define rep(i,j) FOR(i,0,j)
#define each(x,y) for(auto &(x):(y))
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define debug(x) cout<<#x<<": "<<(x)<<endl
#define smax(x,y) (x)=max((x),(y))
#define smin(x,y) (x)=min((x),(y))
#define MEM(x,y) memset((x),(y),sizeof (x))
#define sz(x) (int)(x).size()
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;

template<int MOD>
struct ModInt {
    ModInt() :x(0) {}
    ModInt(long long x) :x((int)(x<0 ? MOD + x%MOD : x%MOD)) { }
    ModInt& operator+=(ModInt that) {
        x = x + that.x;
        if (x >= MOD)x -= MOD;
        return *this;
    }
    ModInt& operator-=(ModInt that) {
        x -= that.x;
        if (x<0)x += MOD;
        return *this;
    }
    ModInt& operator*=(ModInt that) {
        x = (int)((long long)x * that.x % MOD);
        return *this;
    }
    ModInt operator+(ModInt that) {
        return ModInt(*this) += that;
    }
    ModInt operator-(ModInt that) {
        return ModInt(*this) -= that;
    }
    ModInt operator*(ModInt that) {
        return ModInt(*this) *= that;
    }
    int x;
};
typedef ModInt<1000000007> mint;

mint f[102][102];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);

    for (int i = 0; i < 102; i++)for (int j = 0; j < 102; j++) {
        if (i >= 1 && j >= 1)f[i][j] = f[i - 1][j] + f[i][j - 1];
        else {
            f[i][j] = 1;
        }
    }
    int n, a, b, c;
    cin >> n;
    auto g = [](int x, int y, int z) {
        mint res;
        for (int i = 1; i <= x; ++i) {
            res += f[i - 1][y - 1] * f[x - i][z];
        }
        return res;
    };
    while (n--) {
        cin >> a >> b >> c;
    
        mint ans = g(a, b, c) + g(b, c, a) + g(c, a, b);
        FOR(i, 1, a + 1)FOR(j, 1, b + 1)FOR(k, 1, c + 1) {
            ans += f[a - i][j - 1] * f[b - j][k - 1] * f[c - k][i - 1];
        }
        cout << ans.x << endl;
    }
}
0