結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
trineutron
|
| 提出日時 | 2020-02-04 15:25:26 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 2,000 ms |
| コード長 | 579 bytes |
| コンパイル時間 | 1,560 ms |
| コンパイル使用メモリ | 170,276 KB |
| 実行使用メモリ | 18,932 KB |
| 最終ジャッジ日時 | 2024-09-21 07:23:11 |
| 合計ジャッジ時間 | 2,546 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
const int64_t mod = 1000000007;
int n, p;
cin >> n >> p;
vector<int64_t> a(n);
if (n > 1) a.at(1) = 1;
for (int i = 2; i < n; i++) {
a.at(i) = p * a.at(i - 1) + a.at(i - 2);
a.at(i) %= mod;
}
int64_t s = 0, s_diag = 0;
for (int i = 0; i < n; i++) {
s += a.at(i);
s %= mod;
s_diag += a.at(i) * a.at(i);
s_diag %= mod;
}
int64_t ans = (s * s + s_diag) % mod;
if (ans % 2) ans += mod;
ans /= 2;
cout << ans << endl;
}
trineutron