結果

問題 No.612 Move on grid
ユーザー pinpin
提出日時 2017-12-12 19:02:34
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,561 bytes
コンパイル時間 934 ms
コンパイル使用メモリ 84,500 KB
実行使用メモリ 6,012 KB
最終ジャッジ日時 2023-08-20 23:25:34
合計ジャッジ時間 7,813 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int T, a, b, c, d, e;
ll combi[600][600];
ll p[600];
void combination(){
    combi[0][0] = combi[1][2] = 1;
    for (int i = 1; i <= 500; i++){
        combi[i][0] = combi[i][i] = 1;
    }

    for (int i = 2; i <= 500; i++){
        for (int j = 1; j < i; j++){
            combi[i][j] = combi[i - 1][j - 1] + combi[i - 1][j];
        }
    }
    return;
}
void power(){
    p[0] = 1;
    for (int i = 1; i <= 500; i++){
        p[i] = p[i - 1] * 2;
        p[i] %= MOD;
    }
}
int main(void){
    cin >> T >> a >> b >> c >> d >> e;
    combination();
    power();

    ll ans = 0;
    for (int x = -T; x <= T; x++){
        for (int y = abs(x) - T; y <= T - abs(x); y++){
            for (int z = abs(x) + abs(y) - T; z <= T - abs(x) - abs(y); z++){
                if (d <= a*x + b*y + c*z && a*x + b*y + c*z <= e){
                    int n = T - abs(x) - abs(y) - abs(z);
                    if (n % 2 == 0){
                        ll a = combi[T][abs(x)] * combi[T - abs(x)][abs(y)] * combi[T - abs(x) - abs(y)][abs(z)];
                        a %= MOD;
                        a *= p[n / 2];
                        a %= MOD;
                        ans += a;
                        ans %= MOD;
                    }
                }
            }
        }
    }

    cout << ans << endl;
}
0