結果

問題 No.1331 Moving Penguin
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-09-08 06:55:20
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 418 ms / 1,500 ms
コード長 810 bytes
コンパイル時間 5,597 ms
コンパイル使用メモリ 310,664 KB
実行使用メモリ 130,992 KB
最終ジャッジ日時 2023-09-08 06:55:46
合計ジャッジ時間 23,698 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
5,956 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 361 ms
130,768 KB
testcase_05 AC 411 ms
130,924 KB
testcase_06 AC 389 ms
130,904 KB
testcase_07 AC 388 ms
130,904 KB
testcase_08 AC 357 ms
130,876 KB
testcase_09 AC 339 ms
130,752 KB
testcase_10 AC 340 ms
130,820 KB
testcase_11 AC 351 ms
130,856 KB
testcase_12 AC 340 ms
130,928 KB
testcase_13 AC 340 ms
130,824 KB
testcase_14 AC 352 ms
130,856 KB
testcase_15 AC 354 ms
130,884 KB
testcase_16 AC 353 ms
130,820 KB
testcase_17 AC 350 ms
130,860 KB
testcase_18 AC 346 ms
130,964 KB
testcase_19 AC 344 ms
130,856 KB
testcase_20 AC 340 ms
130,796 KB
testcase_21 AC 364 ms
130,924 KB
testcase_22 AC 343 ms
130,992 KB
testcase_23 AC 342 ms
130,900 KB
testcase_24 AC 347 ms
130,776 KB
testcase_25 AC 362 ms
130,808 KB
testcase_26 AC 377 ms
130,856 KB
testcase_27 AC 378 ms
130,776 KB
testcase_28 AC 368 ms
130,888 KB
testcase_29 AC 359 ms
130,880 KB
testcase_30 AC 82 ms
27,852 KB
testcase_31 AC 131 ms
57,476 KB
testcase_32 AC 65 ms
23,852 KB
testcase_33 AC 124 ms
40,836 KB
testcase_34 AC 222 ms
72,992 KB
testcase_35 AC 388 ms
130,864 KB
testcase_36 AC 392 ms
130,772 KB
testcase_37 AC 398 ms
130,816 KB
testcase_38 AC 87 ms
30,380 KB
testcase_39 AC 352 ms
125,060 KB
testcase_40 AC 146 ms
48,756 KB
testcase_41 AC 418 ms
130,820 KB
testcase_42 AC 366 ms
130,800 KB
testcase_43 AC 366 ms
130,860 KB
testcase_44 AC 389 ms
130,868 KB
testcase_45 AC 339 ms
130,820 KB
testcase_46 AC 337 ms
130,876 KB
testcase_47 AC 338 ms
130,820 KB
testcase_48 AC 353 ms
130,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint1000000007;
using ll=long long;
using pp=pair<ll,ll>;
#define sr string 
#define vc vector
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
int main(){
  int n;cin>>n;
  int d=sqrt(n); d=max(d,2);
  vc dp(n,vc<mint>(d,0)); 
  vc<mint>dx(n,0); dx[0]=1;
  rep(i,n){
    int a;cin>>a;
    rep(j,d)dx[i]+=dp[i][j];
    dx[i+1]+=dx[i];
    if(a>=d)for(int j=i+a;j<n;j+=a)dx[j]+=dx[i];
    else{
      if(a>1)dp[i][a]+=dx[i];
      else if(i+2<n)dp[i+2][1]+=dx[i];      
    }
    rep(j,d)if(i+j<n)dp[i+j][j]+=dp[i][j];
  }
  cout<<dx[n-1].val();
}
      
    
0