結果

問題 No.612 Move on grid
ユーザー mamekinmamekin
提出日時 2018-01-14 00:26:10
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 58 ms / 2,500 ms
コード長 1,176 bytes
コンパイル時間 951 ms
コンパイル使用メモリ 103,460 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-25 16:03:37
合計ジャッジ時間 2,371 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 9 ms
4,380 KB
testcase_05 AC 58 ms
4,376 KB
testcase_06 AC 53 ms
4,376 KB
testcase_07 AC 10 ms
4,380 KB
testcase_08 AC 53 ms
4,376 KB
testcase_09 AC 27 ms
4,380 KB
testcase_10 AC 19 ms
4,376 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 30 ms
4,376 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 40 ms
4,376 KB
testcase_15 AC 7 ms
4,380 KB
testcase_16 AC 47 ms
4,376 KB
testcase_17 AC 8 ms
4,376 KB
testcase_18 AC 37 ms
4,380 KB
testcase_19 AC 14 ms
4,376 KB
testcase_20 AC 20 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MOD = 1000000007;

int main()
{
    int t;
    cin >> t;
    vector<int> v(6);
    for(int i=0; i<3; ++i){
        cin >> v[2*i];
        v[2*i+1] = -v[2*i];
    }
    int a, b;
    cin >> a >> b;

    vector<int> dp(20001, 0);
    dp[10000] = 1;
    while(--t >= 0){
        vector<int> nextDp(20001, 0);
        for(int i=0; i<=20000; ++i){
            if(dp[i] == 0)
                continue;
            for(int j=0; j<6; ++j){
                nextDp[i+v[j]] += dp[i];
                nextDp[i+v[j]] %= MOD;
            }
        }
        dp.swap(nextDp);
    }

    int ans = 0;
    for(int i=a+10000; i<=b+10000; ++i){
        ans += dp[i];
        ans %= MOD;
    }
    cout << ans << endl;

    return 0;
}
0