結果

問題 No.1331 Moving Penguin
ユーザー 👑 deuteridayodeuteridayo
提出日時 2021-01-17 04:08:11
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,038 ms / 1,500 ms
コード長 834 bytes
コンパイル時間 1,440 ms
コンパイル使用メモリ 171,508 KB
実行使用メモリ 399,032 KB
最終ジャッジ日時 2023-08-07 11:20:26
合計ジャッジ時間 45,238 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
31,824 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1,033 ms
398,656 KB
testcase_05 AC 1,012 ms
398,768 KB
testcase_06 AC 1,001 ms
398,772 KB
testcase_07 AC 992 ms
398,692 KB
testcase_08 AC 993 ms
398,740 KB
testcase_09 AC 994 ms
398,796 KB
testcase_10 AC 1,018 ms
398,820 KB
testcase_11 AC 1,019 ms
398,696 KB
testcase_12 AC 1,001 ms
398,692 KB
testcase_13 AC 992 ms
398,820 KB
testcase_14 AC 996 ms
398,720 KB
testcase_15 AC 1,009 ms
398,768 KB
testcase_16 AC 1,009 ms
398,808 KB
testcase_17 AC 1,010 ms
398,688 KB
testcase_18 AC 1,020 ms
398,872 KB
testcase_19 AC 1,014 ms
398,712 KB
testcase_20 AC 1,031 ms
398,700 KB
testcase_21 AC 1,002 ms
398,768 KB
testcase_22 AC 1,002 ms
398,744 KB
testcase_23 AC 1,011 ms
398,768 KB
testcase_24 AC 1,018 ms
398,700 KB
testcase_25 AC 1,018 ms
398,744 KB
testcase_26 AC 1,038 ms
398,736 KB
testcase_27 AC 1,018 ms
398,748 KB
testcase_28 AC 1,007 ms
399,032 KB
testcase_29 AC 1,018 ms
398,704 KB
testcase_30 AC 333 ms
134,832 KB
testcase_31 AC 581 ms
226,296 KB
testcase_32 AC 300 ms
119,304 KB
testcase_33 AC 441 ms
177,268 KB
testcase_34 AC 673 ms
268,328 KB
testcase_35 AC 1,000 ms
398,696 KB
testcase_36 AC 1,001 ms
398,808 KB
testcase_37 AC 1,004 ms
398,744 KB
testcase_38 AC 355 ms
141,456 KB
testcase_39 AC 989 ms
385,760 KB
testcase_40 AC 508 ms
199,800 KB
testcase_41 AC 1,016 ms
398,692 KB
testcase_42 AC 1,020 ms
398,768 KB
testcase_43 AC 1,017 ms
398,876 KB
testcase_44 AC 1,012 ms
398,696 KB
testcase_45 AC 1,015 ms
398,816 KB
testcase_46 AC 1,009 ms
398,712 KB
testcase_47 AC 1,002 ms
398,744 KB
testcase_48 AC 1,010 ms
398,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
// #include<atcoder/all>
using namespace std;
// using namespace atcoder;
using lint = long long;
#define endl '\n'
lint const mod = 1e9+7;
//long const mod = 998244353;


int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin >> a[i];
    vector<lint>dp(n);
    dp[0] = 1;
    vector<vector<int>>sum(n,vector<int>(1000));
    for(int i=0;i<n;i++){
        for(int j=1;j<1000;j++){
            dp[i] += sum[i%j][j];
            dp[i] %= mod;
        }
        if(i == n-1)break;
        if(a[i] != 1)dp[i+1] += dp[i];
        if(a[i] < 1000){
            sum[i%a[i]][a[i]] += dp[i];
            sum[i%a[i]][a[i]] %= mod;
        }else{
            for(int j = i + a[i]; j<n; j+=a[i]){
                dp[j] += dp[i];
            }
        }
        
    }
    cout << dp[n-1] << endl;
}
0