結果

問題 No.612 Move on grid
ユーザー ふっぴーふっぴー
提出日時 2017-12-13 11:25:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 2,500 ms
コード長 1,441 bytes
コンパイル時間 1,846 ms
コンパイル使用メモリ 171,364 KB
実行使用メモリ 121,592 KB
最終ジャッジ日時 2023-08-22 22:17:29
合計ジャッジ時間 4,485 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 3 ms
4,380 KB
testcase_02 AC 3 ms
4,884 KB
testcase_03 AC 30 ms
31,772 KB
testcase_04 AC 117 ms
121,520 KB
testcase_05 AC 175 ms
121,592 KB
testcase_06 AC 166 ms
121,576 KB
testcase_07 AC 113 ms
121,524 KB
testcase_08 AC 166 ms
121,520 KB
testcase_09 AC 135 ms
121,580 KB
testcase_10 AC 91 ms
77,304 KB
testcase_11 AC 38 ms
38,416 KB
testcase_12 AC 113 ms
91,292 KB
testcase_13 AC 55 ms
52,932 KB
testcase_14 AC 137 ms
105,720 KB
testcase_15 AC 42 ms
40,584 KB
testcase_16 AC 156 ms
120,072 KB
testcase_17 AC 52 ms
54,996 KB
testcase_18 AC 137 ms
107,864 KB
testcase_19 AC 86 ms
84,404 KB
testcase_20 AC 122 ms
114,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
  int t, i, j;
  cin >> t;
  int a, b, c, d, e;
  cin >> a >> b >> c >> d >> e;
  vll dp(t + 1, vl(30000));
  dp[0][15000] = 1;
  for (i = 0; i < t; i++) {
    for (j = 0; j < 30000; j++) {
      if (dp[i][j]) {
	dp[i + 1][j + a] += dp[i][j];
	dp[i + 1][j - a] += dp[i][j];
	dp[i + 1][j + b] += dp[i][j];
	dp[i + 1][j - b] += dp[i][j];
	dp[i + 1][j + c] += dp[i][j];
	dp[i + 1][j - c] += dp[i][j];
	dp[i + 1][j + a] %= MOD;
	dp[i + 1][j - a] %= MOD;
	dp[i + 1][j + b] %= MOD;
	dp[i + 1][j - b] %= MOD;
	dp[i + 1][j + c] %= MOD;
	dp[i + 1][j - c] %= MOD;
      }
    }
  }
  ll ans = 0;
  for (i = d + 15000; i <= e + 15000; i++) {
    ans += dp[t][i];
    ans %= MOD;
  }
  cout << ans << endl;
}
0