結果

問題 No.1331 Moving Penguin
ユーザー どららどらら
提出日時 2021-01-09 02:52:08
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 632 ms / 1,500 ms
コード長 974 bytes
コンパイル時間 1,735 ms
コンパイル使用メモリ 162,596 KB
実行使用メモリ 9,088 KB
最終ジャッジ日時 2024-04-25 05:03:23
合計ジャッジ時間 27,179 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
6,528 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 632 ms
9,088 KB
testcase_05 AC 586 ms
5,632 KB
testcase_06 AC 608 ms
5,504 KB
testcase_07 AC 586 ms
5,632 KB
testcase_08 AC 572 ms
5,376 KB
testcase_09 AC 593 ms
5,376 KB
testcase_10 AC 590 ms
5,376 KB
testcase_11 AC 596 ms
5,376 KB
testcase_12 AC 597 ms
5,376 KB
testcase_13 AC 566 ms
5,376 KB
testcase_14 AC 595 ms
5,376 KB
testcase_15 AC 592 ms
5,376 KB
testcase_16 AC 590 ms
5,376 KB
testcase_17 AC 605 ms
5,376 KB
testcase_18 AC 598 ms
5,376 KB
testcase_19 AC 602 ms
5,376 KB
testcase_20 AC 601 ms
5,376 KB
testcase_21 AC 557 ms
5,376 KB
testcase_22 AC 587 ms
5,376 KB
testcase_23 AC 599 ms
5,376 KB
testcase_24 AC 585 ms
5,376 KB
testcase_25 AC 596 ms
5,376 KB
testcase_26 AC 557 ms
8,064 KB
testcase_27 AC 561 ms
7,936 KB
testcase_28 AC 563 ms
7,936 KB
testcase_29 AC 613 ms
5,376 KB
testcase_30 AC 190 ms
7,296 KB
testcase_31 AC 321 ms
7,680 KB
testcase_32 AC 168 ms
7,168 KB
testcase_33 AC 246 ms
7,296 KB
testcase_34 AC 377 ms
7,808 KB
testcase_35 AC 575 ms
6,400 KB
testcase_36 AC 577 ms
6,272 KB
testcase_37 AC 571 ms
6,400 KB
testcase_38 AC 205 ms
7,168 KB
testcase_39 AC 548 ms
8,064 KB
testcase_40 AC 277 ms
7,680 KB
testcase_41 AC 553 ms
6,784 KB
testcase_42 AC 572 ms
5,376 KB
testcase_43 AC 579 ms
5,376 KB
testcase_44 AC 581 ms
5,376 KB
testcase_45 AC 557 ms
5,376 KB
testcase_46 AC 543 ms
5,376 KB
testcase_47 AC 558 ms
5,376 KB
testcase_48 AC 595 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

static const ll MOD = 1000000007;

int N;
ll v[100005];
ll dp[100005];

ll memo[1005][1005];

int main(){
  cin >> N;
  rep(i,N){
    cin >> v[i+1];
  }
  
  dp[1] = 1;

  REP(i,1,N+1){
    REP(j,1,1005){
      dp[i] += memo[j][i%j];
      dp[i] %= MOD;
    }
    if(v[i] <= 1000){
      memo[v[i]][i%v[i]] += dp[i];
      memo[v[i]][i%v[i]] %= MOD;
      if(v[i] != 1){
        dp[i+1] += dp[i];
        dp[i+1] %= MOD;
      }
    }else{
      dp[i+1] += dp[i];
      dp[i+1] %= MOD;

      int p = v[i];
      int j = 1;
      while(p*j<=N){
        dp[i+p*j] += dp[i];
        dp[i+p*j] %= MOD;
        j++;
      }
    }
  }

  cout << dp[N] << endl;
  
  return 0;
}
0