結果

問題 No.1331 Moving Penguin
ユーザー penguinmanpenguinman
提出日時 2020-10-30 22:34:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 1,500 ms
コード長 863 bytes
コンパイル時間 1,501 ms
コンパイル使用メモリ 169,300 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 04:33:23
合計ジャッジ時間 9,649 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 173 ms
5,376 KB
testcase_05 AC 167 ms
5,376 KB
testcase_06 AC 161 ms
5,376 KB
testcase_07 AC 166 ms
5,376 KB
testcase_08 AC 160 ms
5,376 KB
testcase_09 AC 162 ms
5,376 KB
testcase_10 AC 166 ms
5,376 KB
testcase_11 AC 163 ms
5,376 KB
testcase_12 AC 164 ms
5,376 KB
testcase_13 AC 161 ms
5,376 KB
testcase_14 AC 163 ms
5,376 KB
testcase_15 AC 161 ms
5,376 KB
testcase_16 AC 162 ms
5,376 KB
testcase_17 AC 159 ms
5,376 KB
testcase_18 AC 157 ms
5,376 KB
testcase_19 AC 158 ms
5,376 KB
testcase_20 AC 161 ms
5,376 KB
testcase_21 AC 162 ms
5,376 KB
testcase_22 AC 160 ms
5,376 KB
testcase_23 AC 158 ms
5,376 KB
testcase_24 AC 160 ms
5,376 KB
testcase_25 AC 157 ms
5,376 KB
testcase_26 AC 176 ms
5,376 KB
testcase_27 AC 179 ms
5,376 KB
testcase_28 AC 172 ms
5,376 KB
testcase_29 AC 177 ms
5,376 KB
testcase_30 AC 38 ms
5,376 KB
testcase_31 AC 79 ms
5,376 KB
testcase_32 AC 34 ms
5,376 KB
testcase_33 AC 53 ms
5,376 KB
testcase_34 AC 101 ms
5,376 KB
testcase_35 AC 182 ms
5,376 KB
testcase_36 AC 185 ms
5,376 KB
testcase_37 AC 188 ms
5,376 KB
testcase_38 AC 40 ms
5,376 KB
testcase_39 AC 165 ms
5,376 KB
testcase_40 AC 62 ms
5,376 KB
testcase_41 AC 165 ms
5,376 KB
testcase_42 AC 183 ms
5,376 KB
testcase_43 AC 183 ms
5,376 KB
testcase_44 AC 190 ms
5,376 KB
testcase_45 AC 208 ms
5,376 KB
testcase_46 AC 204 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 std::cin;
using std::cout;
using std::endl;
using std::vector;
const int mod=1e9+7;
int main(){
    const int max=1e5;
    int N; cin>>N;
    assert(2<=N&&N<=max);
    int M=sqrt(N);
    vector<int> dp(N);
    vector<vector<int>> sum(M+1,vector<int>(M+1));
    dp[0]=1;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        assert(1<=A[i]&&A[i]<=N);
        if(i>0&&A[i-1]>1){
            dp[i]+=dp[i-1];
            dp[i]%=mod;
        }
        for(int j=1;j<=M;j++){
            dp[i]+=sum[j][i%j];
            dp[i]%=mod;
        }
        if(A[i]<=M){
            sum[A[i]][i%A[i]]+=dp[i];
            sum[A[i]][i%A[i]]%=mod;
        }
        else{
            for(int j=i+A[i];j<N;j+=A[i]){
                dp[j]+=dp[i];
                dp[j]%=mod;
            }
        }
    }
    cout<<dp[N-1]<<endl;
}
0