結果
問題 |
No.978 Fibonacci Convolution Easy
|
ユーザー |
![]() |
提出日時 | 2020-02-01 02:04:08 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 38 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 718 ms |
コンパイル使用メモリ | 81,732 KB |
実行使用メモリ | 19,056 KB |
最終ジャッジ日時 | 2024-09-18 21:04:35 |
合計ジャッジ時間 | 1,738 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 21 |
ソースコード
#include<iostream> #include<algorithm> #include<vector> #include<string> #include<utility> #include<map> #include<set> #include<queue> #include<stack> #include<math.h> using namespace std; #define mod (1000000000+7) #define N (10007) #define INF 1e16 typedef long long ll; typedef pair<ll,ll> P; ll dp[2000010]; int main(){ ll n,p; cin>>n>>p; dp[0]=0; dp[1]=0; dp[2]=1; for(ll i=3;i<=n;i++){ dp[i] = (p*dp[i-1])%mod; dp[i] = (dp[i]+dp[i-2])%mod; } ll ans = 0,sum = 0; for(ll i=1;i<=n;i++){ ll tmp = dp[i]; sum = (sum + dp[i])%mod; ans = ans + (dp[i]*sum)%mod; ans = ans%mod; } cout<<(ans+mod)%mod<<endl; }