結果
問題 |
No.978 Fibonacci Convolution Easy
|
ユーザー |
|
提出日時 | 2020-02-02 09:08:46 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 118 ms |
コンパイル使用メモリ | 23,296 KB |
実行使用メモリ | 32,768 KB |
最終ジャッジ日時 | 2024-09-18 21:07:28 |
合計ジャッジ時間 | 1,184 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:9:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 9 | scanf("%d%d", &n, &p); | ~~~~~^~~~~~~~~~~~~~~~
ソースコード
#include <stdio.h> constexpr int kN = int(2E6 + 10), kMod = 1000000007; typedef long long int ll; ll a[kN], s[kN]; int main() { int n, p; ll ans = 0; scanf("%d%d", &n, &p); a[1] = 0, a[2] = 1; for (int i = 3; i <= n; i++) a[i] = (a[i - 1] * p + a[i - 2]) % kMod; s[1] = 0; for (int i = 2; i <= n; i++) s[i] = (s[i - 1] + a[i]) % kMod; for (int i = 1; i <= n; i++) ans += a[i] * s[i] % kMod; printf("%lld\n", ans % kMod); }