結果

問題 No.978 Fibonacci Convolution Easy
コンテスト
ユーザー tadanoningen
提出日時 2020-10-08 04:09:05
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 780 ms
コンパイル使用メモリ 76,388 KB
実行使用メモリ 18,940 KB
最終ジャッジ日時 2024-07-20 05:41:28
合計ジャッジ時間 1,930 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#define ll long long
#define mod 1000000007

using namespace std;

int main(){
  ll n,p;
  cin >> n >> p;
  cout << 2 << endl;
  vector<ll> dp(n+1);
  dp[1] = 0;dp[2] = 1;
  for(int i=3;i < n+1;i++) dp[i] = p*dp[i-1]%mod + dp[i-2]%mod;
  ll ans = 0;
  ll sum = 0;
  for(int i=1;i <= n;i++){
    sum += dp[i];
    sum %= mod;
    ans += sum*dp[i] % mod;
    ans = (ans+mod)%mod;
  }
  cout << 3 << endl;
  cout << ans << endl;
  return 0;
}
0