結果
問題 | No.978 Fibonacci Convolution Easy |
ユーザー |
|
提出日時 | 2025-05-21 15:35:06 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 16 ms / 2,000 ms |
コード長 | 540 bytes |
コンパイル時間 | 2,805 ms |
コンパイル使用メモリ | 278,364 KB |
実行使用メモリ | 11,080 KB |
最終ジャッジ日時 | 2025-05-21 15:35:11 |
合計ジャッジ時間 | 4,263 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include <bits/stdc++.h> #include <atcoder/modint> using namespace std; using namespace atcoder; using ll = long long; using mint = modint1000000007; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); ll N, P; cin >> N >> P; if(N == 1) { cout << 0 << "\n"; } if(N == 2) { cout << 1 << "\n"; } if(N < 3) { return 0; } mint S = 1, ans = 1; vector<mint> A(N, 0); A[1] = 1; for(ll i = 2; i < N; i++) { A[i] = A[i - 1] * P + A[i - 2]; S += A[i]; ans += S * A[i]; } cout << ans.val() << "\n"; }