結果
問題 |
No.980 Fibonacci Convolution Hard
|
ユーザー |
![]() |
提出日時 | 2020-02-01 01:32:39 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 360 ms / 2,000 ms |
コード長 | 885 bytes |
コンパイル時間 | 1,575 ms |
コンパイル使用メモリ | 168,560 KB |
実行使用メモリ | 34,648 KB |
最終ジャッジ日時 | 2024-09-17 15:55:47 |
合計ジャッジ時間 | 9,658 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> P; ll const mod = 1e9+7; #define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0) #define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0) int main() { ll p; int q; cin >> p; vector<ll> ans(2000010),a(2000010); a[1] = 0; a[2] = 1; for (int i = 3;i < 2000010;++i) a[i] = (p*a[i-1]+a[i-2])%mod; ans[1] = 0; ans[2] = 0; for (int i = 3;i < 2000010;++i) ans[i] = (p*ans[i-1]+ans[i-2]+a[i-2])%mod; cin >> q; for (int i = 0;i < q;++i) { int t; cin >> t; cout << ans[t] << "\n"; } }