結果

問題 No.1331 Moving Penguin
ユーザー spihillspihill
提出日時 2021-01-09 00:19:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 175 ms / 1,500 ms
コード長 643 bytes
コンパイル時間 2,001 ms
コンパイル使用メモリ 198,108 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 04:58:47
合計ジャッジ時間 9,801 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 14 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 170 ms
5,376 KB
testcase_05 AC 152 ms
5,376 KB
testcase_06 AC 153 ms
5,376 KB
testcase_07 AC 153 ms
5,376 KB
testcase_08 AC 148 ms
5,376 KB
testcase_09 AC 150 ms
5,376 KB
testcase_10 AC 147 ms
5,376 KB
testcase_11 AC 155 ms
5,376 KB
testcase_12 AC 151 ms
5,376 KB
testcase_13 AC 150 ms
5,376 KB
testcase_14 AC 152 ms
5,376 KB
testcase_15 AC 150 ms
5,376 KB
testcase_16 AC 149 ms
5,376 KB
testcase_17 AC 148 ms
5,376 KB
testcase_18 AC 148 ms
5,376 KB
testcase_19 AC 149 ms
5,376 KB
testcase_20 AC 147 ms
5,376 KB
testcase_21 AC 146 ms
5,376 KB
testcase_22 AC 150 ms
5,376 KB
testcase_23 AC 147 ms
5,376 KB
testcase_24 AC 145 ms
5,376 KB
testcase_25 AC 147 ms
5,376 KB
testcase_26 AC 158 ms
5,376 KB
testcase_27 AC 161 ms
5,376 KB
testcase_28 AC 157 ms
5,376 KB
testcase_29 AC 161 ms
5,376 KB
testcase_30 AC 54 ms
5,376 KB
testcase_31 AC 90 ms
5,376 KB
testcase_32 AC 49 ms
5,376 KB
testcase_33 AC 73 ms
5,376 KB
testcase_34 AC 107 ms
5,376 KB
testcase_35 AC 175 ms
5,376 KB
testcase_36 AC 171 ms
5,376 KB
testcase_37 AC 171 ms
5,376 KB
testcase_38 AC 58 ms
5,376 KB
testcase_39 AC 154 ms
5,376 KB
testcase_40 AC 81 ms
5,376 KB
testcase_41 AC 154 ms
5,376 KB
testcase_42 AC 169 ms
5,376 KB
testcase_43 AC 165 ms
5,376 KB
testcase_44 AC 173 ms
5,376 KB
testcase_45 AC 171 ms
5,376 KB
testcase_46 AC 167 ms
5,376 KB
testcase_47 AC 174 ms
5,376 KB
testcase_48 AC 151 ms
5,376 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