結果

問題 No.1331 Moving Penguin
ユーザー spihillspihill
提出日時 2021-01-09 00:19:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 191 ms / 1,500 ms
コード長 643 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 202,696 KB
実行使用メモリ 4,424 KB
最終ジャッジ日時 2023-08-07 11:06:26
合計ジャッジ時間 11,085 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 173 ms
4,392 KB
testcase_05 AC 164 ms
4,380 KB
testcase_06 AC 166 ms
4,400 KB
testcase_07 AC 164 ms
4,424 KB
testcase_08 AC 163 ms
4,376 KB
testcase_09 AC 163 ms
4,380 KB
testcase_10 AC 162 ms
4,380 KB
testcase_11 AC 163 ms
4,380 KB
testcase_12 AC 163 ms
4,376 KB
testcase_13 AC 162 ms
4,380 KB
testcase_14 AC 162 ms
4,380 KB
testcase_15 AC 162 ms
4,380 KB
testcase_16 AC 162 ms
4,380 KB
testcase_17 AC 161 ms
4,380 KB
testcase_18 AC 163 ms
4,376 KB
testcase_19 AC 162 ms
4,384 KB
testcase_20 AC 162 ms
4,376 KB
testcase_21 AC 162 ms
4,376 KB
testcase_22 AC 162 ms
4,376 KB
testcase_23 AC 162 ms
4,376 KB
testcase_24 AC 163 ms
4,376 KB
testcase_25 AC 162 ms
4,380 KB
testcase_26 AC 176 ms
4,380 KB
testcase_27 AC 177 ms
4,384 KB
testcase_28 AC 173 ms
4,380 KB
testcase_29 AC 176 ms
4,380 KB
testcase_30 AC 59 ms
4,384 KB
testcase_31 AC 99 ms
4,380 KB
testcase_32 AC 52 ms
4,380 KB
testcase_33 AC 78 ms
4,376 KB
testcase_34 AC 117 ms
4,380 KB
testcase_35 AC 189 ms
4,376 KB
testcase_36 AC 186 ms
4,384 KB
testcase_37 AC 191 ms
4,380 KB
testcase_38 AC 63 ms
4,384 KB
testcase_39 AC 171 ms
4,380 KB
testcase_40 AC 88 ms
4,380 KB
testcase_41 AC 165 ms
4,396 KB
testcase_42 AC 183 ms
4,376 KB
testcase_43 AC 182 ms
4,380 KB
testcase_44 AC 183 ms
4,388 KB
testcase_45 AC 187 ms
4,380 KB
testcase_46 AC 184 ms
4,380 KB
testcase_47 AC 183 ms
4,376 KB
testcase_48 AC 163 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

constexpr int mod = 1e9 + 7;
constexpr int S = 320;

int main() {
    int N; cin >> N;
    vector<int> A(N), dp1(N);
    for (auto& x : A) cin >> x;
    dp1[0] = 1;
    vector<vector<int>> dp2(S);
    for (int i = 0; i < S; i++) dp2[i] = vector<int>(i);
    for (int i = 0; i < N; i++) {
        for (int j = 1; j < S; j++) (dp1[i] += dp2[j][i % j]) %= mod; 
        if (A[i] < S) (dp2[A[i]][i % A[i]] += dp1[i]) %= mod;
        else for (int j = i + A[i]; j < N; j += A[i]) (dp1[j] += dp1[i]) %= mod;
		if (A[i] != 1 && i != N-1) (dp1[i+1] += dp1[i]) %= mod;
    }
    cout << dp1[N-1] << endl;
}
0