結果

問題 No.1331 Moving Penguin
ユーザー penguinmanpenguinman
提出日時 2020-10-15 02:00:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 210 ms / 1,500 ms
コード長 780 bytes
コンパイル時間 1,690 ms
コンパイル使用メモリ 167,760 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 04:31:25
合計ジャッジ時間 9,753 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,248 KB
testcase_01 AC 2 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 162 ms
5,376 KB
testcase_06 AC 166 ms
5,376 KB
testcase_07 AC 161 ms
5,376 KB
testcase_08 AC 156 ms
5,376 KB
testcase_09 AC 159 ms
5,376 KB
testcase_10 AC 162 ms
5,376 KB
testcase_11 AC 161 ms
5,376 KB
testcase_12 AC 159 ms
5,376 KB
testcase_13 AC 162 ms
5,376 KB
testcase_14 AC 160 ms
5,376 KB
testcase_15 AC 160 ms
5,376 KB
testcase_16 AC 161 ms
5,376 KB
testcase_17 AC 158 ms
5,376 KB
testcase_18 AC 160 ms
5,376 KB
testcase_19 AC 159 ms
5,376 KB
testcase_20 AC 162 ms
5,376 KB
testcase_21 AC 163 ms
5,376 KB
testcase_22 AC 157 ms
5,376 KB
testcase_23 AC 159 ms
5,376 KB
testcase_24 AC 159 ms
5,376 KB
testcase_25 AC 160 ms
5,376 KB
testcase_26 AC 178 ms
5,376 KB
testcase_27 AC 173 ms
5,376 KB
testcase_28 AC 171 ms
5,376 KB
testcase_29 AC 170 ms
5,376 KB
testcase_30 AC 36 ms
5,376 KB
testcase_31 AC 73 ms
5,376 KB
testcase_32 AC 30 ms
5,376 KB
testcase_33 AC 52 ms
5,376 KB
testcase_34 AC 104 ms
5,376 KB
testcase_35 AC 185 ms
5,376 KB
testcase_36 AC 185 ms
5,376 KB
testcase_37 AC 186 ms
5,376 KB
testcase_38 AC 38 ms
5,376 KB
testcase_39 AC 167 ms
5,376 KB
testcase_40 AC 63 ms
5,376 KB
testcase_41 AC 167 ms
5,376 KB
testcase_42 AC 196 ms
5,376 KB
testcase_43 AC 187 ms
5,376 KB
testcase_44 AC 182 ms
5,376 KB
testcase_45 AC 196 ms
5,376 KB
testcase_46 AC 210 ms
5,376 KB
testcase_47 AC 205 ms
5,376 KB
testcase_48 AC 161 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(){
    int N; cin>>N;
    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];
        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