結果

問題 No.978 Fibonacci Convolution Easy
ユーザー tonegawatonegawa
提出日時 2020-02-01 00:32:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 986 bytes
コンパイル時間 844 ms
コンパイル使用メモリ 95,512 KB
実行使用メモリ 34,652 KB
最終ジャッジ日時 2023-10-19 01:08:08
合計ジャッジ時間 2,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 23 ms
15,464 KB
testcase_02 AC 14 ms
9,596 KB
testcase_03 AC 51 ms
33,400 KB
testcase_04 AC 15 ms
10,848 KB
testcase_05 AC 5 ms
4,912 KB
testcase_06 AC 20 ms
13,948 KB
testcase_07 AC 34 ms
22,652 KB
testcase_08 AC 25 ms
16,784 KB
testcase_09 AC 38 ms
25,684 KB
testcase_10 AC 53 ms
34,652 KB
testcase_11 AC 18 ms
12,168 KB
testcase_12 AC 5 ms
4,648 KB
testcase_13 AC 21 ms
13,684 KB
testcase_14 AC 8 ms
6,232 KB
testcase_15 AC 22 ms
15,200 KB
testcase_16 AC 53 ms
34,652 KB
testcase_17 AC 53 ms
34,416 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll n, p;std::cin >> n >> p;
  ll P = 1000000007;
  vll a(n, 0), s(n, 0);
  a[0] = 0, a[1] = 1;
  rep(i, 2, n) a[i] = ((p*a[i-1])%P + a[i-2])%P;
  re(i, n) s[i] = ((i==0?0:s[i-1]) + a[i])%P;
  ll ans = 0;
  re(i, n){
    ans = (ans + (a[i]*s[i])%P)%P;
  }
  std::cout << ans << '\n';
  return 0;
}
0