結果
問題 | No.1331 Moving Penguin |
ユーザー |
|
提出日時 | 2021-01-08 21:59:45 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 233 ms / 1,500 ms |
コード長 | 1,126 bytes |
コンパイル時間 | 2,417 ms |
コンパイル使用メモリ | 191,556 KB |
最終ジャッジ日時 | 2025-01-17 11:57:57 |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 49 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:34:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 34 | int n; scanf("%d", &n); | ~~~~~^~~~~~~~~~ main.cpp:35:24: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 35 | REP(i, n) scanf("%d", a+i); | ~~~~~^~~~~~~~~~~
ソースコード
#include <bits/stdc++.h>using namespace std;#define REP(i, n) FOR(i, 0, (n))#define FOR(i, a, b) for(int i=(a); i<(b); i++)#define LAR(a, b) ((a)=max((a),(b)))#define SML(a, b) ((a)=min((a),(b)))using ll = long long;using ld = long double;using vi = vector<int>;using vl = vector<ll>;using pii = pair<int, int>;using vpii = vector<pair<int, int>>;template<typename T>using pque = priority_queue<T, vector<T>, greater<T>>;#define PB push_back#define EB emplace_back#define MP make_pair#define ALL(a) (a).begin(), (a).end()#ifdef LOCAL_DEBUG#define DEBUG(...) printf(__VA_ARGS__)#else#define DEBUG(...)#endif#define MOD 1'000'000'007LL#define N 112345#define M 316int a[N];ll b[M][M];ll c[N] = {};int main(){int n; scanf("%d", &n);REP(i, n) scanf("%d", a+i);for(int i = n-1; i >= 0; i--){if(i == n-1) {c[i] = 1;} else if(a[i] >= M){c[i] += c[i+1];for(int j = i+a[i]; j < n; j += a[i]) c[i] += c[j];} else {if(a[i] > 1) c[i] += c[i+1];c[i] += b[a[i]][i%a[i]];}c[i] %= MOD;FOR(j, 1, M) b[j][i%j] = (b[j][i%j] + c[i]) % MOD;}printf("%lld\n", c[0]);}