結果

問題 No.1331 Moving Penguin
ユーザー どららどらら
提出日時 2021-01-09 02:48:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 224 ms / 1,500 ms
コード長 970 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 162,828 KB
実行使用メモリ 6,016 KB
最終ジャッジ日時 2024-04-25 04:59:24
合計ジャッジ時間 10,665 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 183 ms
5,888 KB
testcase_05 AC 173 ms
5,376 KB
testcase_06 AC 174 ms
5,376 KB
testcase_07 AC 173 ms
5,376 KB
testcase_08 AC 168 ms
5,376 KB
testcase_09 AC 167 ms
5,376 KB
testcase_10 AC 168 ms
5,376 KB
testcase_11 AC 173 ms
5,376 KB
testcase_12 AC 171 ms
5,376 KB
testcase_13 AC 173 ms
5,376 KB
testcase_14 AC 172 ms
5,376 KB
testcase_15 AC 168 ms
5,376 KB
testcase_16 AC 174 ms
5,376 KB
testcase_17 AC 173 ms
5,376 KB
testcase_18 AC 169 ms
5,376 KB
testcase_19 AC 172 ms
5,376 KB
testcase_20 AC 165 ms
5,376 KB
testcase_21 AC 168 ms
5,376 KB
testcase_22 AC 174 ms
5,376 KB
testcase_23 AC 171 ms
5,376 KB
testcase_24 AC 170 ms
5,376 KB
testcase_25 AC 173 ms
5,376 KB
testcase_26 AC 189 ms
5,632 KB
testcase_27 AC 195 ms
5,760 KB
testcase_28 AC 190 ms
5,760 KB
testcase_29 AC 186 ms
5,376 KB
testcase_30 AC 68 ms
5,376 KB
testcase_31 AC 107 ms
5,376 KB
testcase_32 AC 57 ms
5,376 KB
testcase_33 AC 84 ms
5,376 KB
testcase_34 AC 130 ms
5,504 KB
testcase_35 AC 224 ms
5,376 KB
testcase_36 AC 221 ms
5,376 KB
testcase_37 AC 224 ms
5,376 KB
testcase_38 AC 69 ms
5,376 KB
testcase_39 AC 186 ms
5,760 KB
testcase_40 AC 95 ms
5,376 KB
testcase_41 AC 180 ms
6,016 KB
testcase_42 AC 201 ms
5,376 KB
testcase_43 AC 200 ms
5,376 KB
testcase_44 AC 207 ms
5,376 KB
testcase_45 AC 220 ms
5,376 KB
testcase_46 AC 200 ms
5,376 KB
testcase_47 AC 200 ms
5,376 KB
testcase_48 AC 169 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007;

int N;
ll v[100005];
ll dp[100005];

ll memo[320][320];

int main(){
  cin >> N;
  rep(i,N){
    cin >> v[i+1];
  }
  
  dp[1] = 1;

  REP(i,1,N+1){
    REP(j,1,320){
      dp[i] += memo[j][i%j];
      dp[i] %= MOD;
    }
    if(v[i] < 320){
      memo[v[i]][i%v[i]] += dp[i];
      memo[v[i]][i%v[i]] %= MOD;
      if(v[i] != 1){
        dp[i+1] += dp[i];
        dp[i+1] %= MOD;
      }
    }else{
      dp[i+1] += dp[i];
      dp[i+1] %= MOD;

      int p = v[i];
      int j = 1;
      while(p*j<=N){
        dp[i+p*j] += dp[i];
        dp[i+p*j] %= MOD;
        j++;
      }
    }
  }

  cout << dp[N] << endl;
  
  return 0;
}

0