結果

問題 No.1331 Moving Penguin
ユーザー どららどらら
提出日時 2021-01-09 02:48:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 231 ms / 1,500 ms
コード長 970 bytes
コンパイル時間 1,394 ms
コンパイル使用メモリ 165,092 KB
実行使用メモリ 5,804 KB
最終ジャッジ日時 2023-08-07 11:07:07
合計ジャッジ時間 11,105 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 190 ms
5,696 KB
testcase_05 AC 181 ms
5,164 KB
testcase_06 AC 179 ms
5,220 KB
testcase_07 AC 179 ms
5,216 KB
testcase_08 AC 177 ms
4,936 KB
testcase_09 AC 175 ms
4,964 KB
testcase_10 AC 177 ms
4,968 KB
testcase_11 AC 176 ms
4,972 KB
testcase_12 AC 176 ms
4,912 KB
testcase_13 AC 176 ms
5,032 KB
testcase_14 AC 177 ms
5,020 KB
testcase_15 AC 178 ms
5,000 KB
testcase_16 AC 177 ms
5,208 KB
testcase_17 AC 176 ms
4,976 KB
testcase_18 AC 177 ms
4,944 KB
testcase_19 AC 177 ms
4,920 KB
testcase_20 AC 177 ms
5,100 KB
testcase_21 AC 177 ms
5,180 KB
testcase_22 AC 176 ms
4,904 KB
testcase_23 AC 176 ms
5,048 KB
testcase_24 AC 177 ms
5,136 KB
testcase_25 AC 177 ms
4,924 KB
testcase_26 AC 196 ms
5,624 KB
testcase_27 AC 198 ms
5,528 KB
testcase_28 AC 201 ms
5,804 KB
testcase_29 AC 191 ms
4,924 KB
testcase_30 AC 67 ms
4,836 KB
testcase_31 AC 113 ms
5,256 KB
testcase_32 AC 60 ms
4,736 KB
testcase_33 AC 88 ms
5,108 KB
testcase_34 AC 133 ms
5,408 KB
testcase_35 AC 228 ms
5,196 KB
testcase_36 AC 231 ms
5,180 KB
testcase_37 AC 227 ms
5,288 KB
testcase_38 AC 70 ms
4,820 KB
testcase_39 AC 191 ms
5,544 KB
testcase_40 AC 98 ms
5,204 KB
testcase_41 AC 185 ms
5,696 KB
testcase_42 AC 210 ms
4,956 KB
testcase_43 AC 210 ms
5,000 KB
testcase_44 AC 210 ms
5,072 KB
testcase_45 AC 209 ms
5,068 KB
testcase_46 AC 210 ms
4,936 KB
testcase_47 AC 211 ms
4,948 KB
testcase_48 AC 177 ms
5,220 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