結果

問題 No.1331 Moving Penguin
ユーザー chocono2230chocono2230
提出日時 2021-01-08 23:59:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 256 ms / 1,500 ms
コード長 1,350 bytes
コンパイル時間 4,695 ms
コンパイル使用メモリ 257,508 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 04:57:45
合計ジャッジ時間 16,150 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 23 ms
5,248 KB
testcase_01 AC 3 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 3 ms
5,376 KB
testcase_04 AC 255 ms
5,376 KB
testcase_05 AC 244 ms
5,376 KB
testcase_06 AC 239 ms
5,376 KB
testcase_07 AC 246 ms
5,376 KB
testcase_08 AC 245 ms
5,376 KB
testcase_09 AC 240 ms
5,376 KB
testcase_10 AC 236 ms
5,376 KB
testcase_11 AC 247 ms
5,376 KB
testcase_12 AC 240 ms
5,376 KB
testcase_13 AC 239 ms
5,376 KB
testcase_14 AC 239 ms
5,376 KB
testcase_15 AC 244 ms
5,376 KB
testcase_16 AC 242 ms
5,376 KB
testcase_17 AC 241 ms
5,376 KB
testcase_18 AC 238 ms
5,376 KB
testcase_19 AC 244 ms
5,376 KB
testcase_20 AC 241 ms
5,376 KB
testcase_21 AC 242 ms
5,376 KB
testcase_22 AC 239 ms
5,376 KB
testcase_23 AC 239 ms
5,376 KB
testcase_24 AC 241 ms
5,376 KB
testcase_25 AC 239 ms
5,376 KB
testcase_26 AC 255 ms
5,376 KB
testcase_27 AC 256 ms
5,376 KB
testcase_28 AC 255 ms
5,376 KB
testcase_29 AC 252 ms
5,376 KB
testcase_30 AC 85 ms
5,376 KB
testcase_31 AC 148 ms
5,376 KB
testcase_32 AC 76 ms
5,376 KB
testcase_33 AC 113 ms
5,376 KB
testcase_34 AC 171 ms
5,376 KB
testcase_35 AC 247 ms
5,376 KB
testcase_36 AC 250 ms
5,376 KB
testcase_37 AC 250 ms
5,376 KB
testcase_38 AC 89 ms
5,376 KB
testcase_39 AC 249 ms
5,376 KB
testcase_40 AC 133 ms
5,376 KB
testcase_41 AC 251 ms
5,376 KB
testcase_42 AC 247 ms
5,376 KB
testcase_43 AC 243 ms
5,376 KB
testcase_44 AC 245 ms
5,376 KB
testcase_45 AC 253 ms
5,376 KB
testcase_46 AC 252 ms
5,376 KB
testcase_47 AC 248 ms
5,376 KB
testcase_48 AC 240 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;

const int sz = 500;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  auto v = vector(sz, vector(sz, mint(0)));
  vector<mint> dp(n+1, 0);
  dp.front() = 1;
  rep2(i, 1, n+1){
    if(i == 1 || a.at(i-2) != 1) dp.at(i) += dp.at(i-1);
    rep2(j, 1, sz){
      dp.at(i) += v.at(j).at(i%j);
    }
    int na = a.at(i-1);
    if(na < sz){
      v.at(na).at(i%na) += dp.at(i);
    }else{
      for(int j = i + na; j < dp.size(); j += na){
        dp.at(j) += dp.at(i);
      }
    }
  }
  // for(auto i : dp){
  //   cerr << i.val() << " ";
  // }
  // cerr << endl;
  // rep(i, 10){
  //   rep(j, 10){
  //     cerr << v.at(i).at(j).val() << " ";
  //   }
  //   cerr << endl;
  // }
  // cerr << endl;
  cout << dp.back().val() << endl;
  return 0;
}
0