結果

問題 No.612 Move on grid
ユーザー kzyKTkzyKT
提出日時 2017-12-13 01:29:29
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 163 ms / 2,500 ms
コード長 1,743 bytes
コンパイル時間 1,281 ms
コンパイル使用メモリ 145,440 KB
実行使用メモリ 99,924 KB
最終ジャッジ日時 2023-08-22 22:17:14
合計ジャッジ時間 4,295 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
99,700 KB
testcase_01 AC 28 ms
99,856 KB
testcase_02 AC 28 ms
99,744 KB
testcase_03 AC 51 ms
99,708 KB
testcase_04 AC 158 ms
99,748 KB
testcase_05 AC 132 ms
99,924 KB
testcase_06 AC 131 ms
99,676 KB
testcase_07 AC 163 ms
99,692 KB
testcase_08 AC 131 ms
99,836 KB
testcase_09 AC 126 ms
99,776 KB
testcase_10 AC 95 ms
99,768 KB
testcase_11 AC 57 ms
99,676 KB
testcase_12 AC 104 ms
99,668 KB
testcase_13 AC 70 ms
99,652 KB
testcase_14 AC 115 ms
99,860 KB
testcase_15 AC 58 ms
99,776 KB
testcase_16 AC 132 ms
99,692 KB
testcase_17 AC 69 ms
99,728 KB
testcase_18 AC 114 ms
99,664 KB
testcase_19 AC 95 ms
99,772 KB
testcase_20 AC 133 ms
99,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

ll dp[555][22222];
void Main() {
  ll T,a,b,c,d,e;
  cin >> T >> a >> b >> c >> d >> e;
  mem(dp);
  dp[0][10000]=1;
  rep(i,T) {
    rep(j,20001) {
      if(j-a>=0) {
        dp[i+1][j-a]+=dp[i][j];
        dp[i+1][j-a]%=MAX;
      }
      if(j-b>=0) {
        dp[i+1][j-b]+=dp[i][j];
        dp[i+1][j-b]%=MAX;
      }
      if(j-c>=0) {
        dp[i+1][j-c]+=dp[i][j];
        dp[i+1][j-c]%=MAX;
      }
      dp[i+1][j+a]+=dp[i][j];
      dp[i+1][j+a]%=MAX;
      dp[i+1][j+b]+=dp[i][j];
      dp[i+1][j+b]%=MAX;
      dp[i+1][j+c]+=dp[i][j];
      dp[i+1][j+c]%=MAX;
    }
  }
  ll ans=0;
  REP(i,10000+d,10000+e+1) {
    ans+=dp[T][i];
    ans%=MAX;
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}
0