結果
| 問題 | No.1331 Moving Penguin |
| コンテスト | |
| ユーザー |
pyonth
|
| 提出日時 | 2021-01-08 21:50:42 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 1,128 bytes |
| 記録 | |
| コンパイル時間 | 3,270 ms |
| コンパイル使用メモリ | 212,216 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-16 11:26:22 |
| 合計ジャッジ時間 | 5,918 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 7 RE * 1 TLE * 1 -- * 40 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define repl(i, l, r) for (ll i = (l); i < (r); i++)
#define rep(i, n) repl(i, 0, n)
#define CST(x) cout << fixed << setprecision(x)
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr int inf = 1e9 + 10;
constexpr ll INF = (ll)4e18 + 10;
constexpr int dx[9] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[9] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
template <class T>
inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T>
inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
int main() {
cin.tie(0);
cout.tie(0);
ios::sync_with_stdio(false);
int n;
cin >> n;
int a[n];
rep(i, n) cin >> a[i];
vector<ll> dp(n);
dp[0] = 1;
rep(i, n - 1) {
if (dp[i] == 0) continue;
for (int j = i + a[i]; j <= n; j += a[i]) {
dp[j] += dp[i];
dp[j] %= MOD;
}
if (a[i] > 1) dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
}
cout << dp[n - 1] << endl;
return 0;
}
pyonth