結果

問題 No.1331 Moving Penguin
ユーザー shiomusubi496shiomusubi496
提出日時 2021-01-08 22:29:02
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 446 ms / 1,500 ms
コード長 508 bytes
コンパイル時間 1,841 ms
コンパイル使用メモリ 167,816 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 04:50:16
合計ジャッジ時間 19,928 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 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 386 ms
5,376 KB
testcase_05 AC 375 ms
5,376 KB
testcase_06 AC 380 ms
5,376 KB
testcase_07 AC 381 ms
5,376 KB
testcase_08 AC 379 ms
5,376 KB
testcase_09 AC 377 ms
5,376 KB
testcase_10 AC 376 ms
5,376 KB
testcase_11 AC 381 ms
5,376 KB
testcase_12 AC 380 ms
5,376 KB
testcase_13 AC 385 ms
5,376 KB
testcase_14 AC 386 ms
5,376 KB
testcase_15 AC 385 ms
5,376 KB
testcase_16 AC 391 ms
5,376 KB
testcase_17 AC 381 ms
5,376 KB
testcase_18 AC 375 ms
5,376 KB
testcase_19 AC 379 ms
5,376 KB
testcase_20 AC 376 ms
5,376 KB
testcase_21 AC 379 ms
5,376 KB
testcase_22 AC 373 ms
5,376 KB
testcase_23 AC 431 ms
5,376 KB
testcase_24 AC 423 ms
5,376 KB
testcase_25 AC 441 ms
5,376 KB
testcase_26 AC 446 ms
5,376 KB
testcase_27 AC 395 ms
5,376 KB
testcase_28 AC 394 ms
5,376 KB
testcase_29 AC 392 ms
5,376 KB
testcase_30 AC 80 ms
5,376 KB
testcase_31 AC 173 ms
5,376 KB
testcase_32 AC 67 ms
5,376 KB
testcase_33 AC 117 ms
5,376 KB
testcase_34 AC 215 ms
5,376 KB
testcase_35 AC 410 ms
5,376 KB
testcase_36 AC 415 ms
5,376 KB
testcase_37 AC 409 ms
5,376 KB
testcase_38 AC 85 ms
5,376 KB
testcase_39 AC 371 ms
5,376 KB
testcase_40 AC 139 ms
5,376 KB
testcase_41 AC 385 ms
5,376 KB
testcase_42 AC 415 ms
5,376 KB
testcase_43 AC 418 ms
5,376 KB
testcase_44 AC 417 ms
5,376 KB
testcase_45 AC 441 ms
5,376 KB
testcase_46 AC 442 ms
5,376 KB
testcase_47 AC 443 ms
5,376 KB
testcase_48 AC 374 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int mod=1000000007;
signed main(){
  int N;cin>>N;
  int S=sqrt(N);
  vector<int>dp(N);dp[0]=1;
  vector<vector<int>>A(S,vector<int>(S));
  for(int i=0;i<N-1;i++){
    int a;cin>>a;
    if(a<S){
      A[a][i%a]=(dp[i]+A[a][i%a])%mod;
    }else{
      for(int j=i+a;j<N;j+=a)dp[j]=(dp[j]+dp[i])%mod;
    }
    if(a!=1)dp[i+1]=(dp[i+1]+dp[i])%mod;
    for(int j=1;j<S;j++)dp[i+1]=(dp[i+1]+A[j][(i+1)%j])%mod;
  }
  cout<<dp[N-1]<<endl;
}
0