結果

問題 No.1331 Moving Penguin
ユーザー penguinmanpenguinman
提出日時 2020-10-15 01:53:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 220 ms / 1,500 ms
コード長 780 bytes
コンパイル時間 2,721 ms
コンパイル使用メモリ 168,960 KB
実行使用メモリ 4,628 KB
最終ジャッジ日時 2023-08-07 10:37:46
合計ジャッジ時間 13,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 187 ms
4,384 KB
testcase_05 AC 176 ms
4,380 KB
testcase_06 AC 177 ms
4,380 KB
testcase_07 AC 177 ms
4,380 KB
testcase_08 AC 175 ms
4,380 KB
testcase_09 AC 174 ms
4,376 KB
testcase_10 AC 174 ms
4,384 KB
testcase_11 AC 176 ms
4,380 KB
testcase_12 AC 175 ms
4,384 KB
testcase_13 AC 175 ms
4,380 KB
testcase_14 AC 175 ms
4,464 KB
testcase_15 AC 175 ms
4,380 KB
testcase_16 AC 176 ms
4,628 KB
testcase_17 AC 174 ms
4,392 KB
testcase_18 AC 173 ms
4,380 KB
testcase_19 AC 173 ms
4,468 KB
testcase_20 AC 174 ms
4,404 KB
testcase_21 AC 174 ms
4,380 KB
testcase_22 AC 174 ms
4,380 KB
testcase_23 AC 173 ms
4,384 KB
testcase_24 AC 175 ms
4,464 KB
testcase_25 AC 175 ms
4,376 KB
testcase_26 AC 188 ms
4,376 KB
testcase_27 AC 187 ms
4,380 KB
testcase_28 AC 188 ms
4,376 KB
testcase_29 AC 188 ms
4,380 KB
testcase_30 AC 39 ms
4,380 KB
testcase_31 AC 82 ms
4,380 KB
testcase_32 AC 33 ms
4,376 KB
testcase_33 AC 57 ms
4,380 KB
testcase_34 AC 105 ms
4,380 KB
testcase_35 AC 202 ms
4,380 KB
testcase_36 AC 200 ms
4,376 KB
testcase_37 AC 200 ms
4,380 KB
testcase_38 AC 41 ms
4,376 KB
testcase_39 AC 178 ms
4,380 KB
testcase_40 AC 68 ms
4,380 KB
testcase_41 AC 180 ms
4,380 KB
testcase_42 AC 202 ms
4,468 KB
testcase_43 AC 203 ms
4,464 KB
testcase_44 AC 202 ms
4,384 KB
testcase_45 AC 220 ms
4,460 KB
testcase_46 AC 220 ms
4,460 KB
testcase_47 AC 220 ms
4,380 KB
testcase_48 AC 174 ms
4,456 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