結果
| 問題 |
No.978 Fibonacci Convolution Easy
|
| ユーザー |
wait_sushi
|
| 提出日時 | 2020-01-31 22:02:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 45 ms / 2,000 ms |
| コード長 | 2,644 bytes |
| コンパイル時間 | 1,395 ms |
| コンパイル使用メモリ | 169,748 KB |
| 実行使用メモリ | 19,792 KB |
| 最終ジャッジ日時 | 2024-09-18 20:58:16 |
| 合計ジャッジ時間 | 2,394 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n) \
vl v; \
rep(i, n) { \
ll x; \
cin >> x; \
v.push_back(x); \
}
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
#include <cstdint>
template <std::uint_fast64_t Modulus> class modint {
using u64 = std::uint_fast64_t;
public:
u64 a;
constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
constexpr u64& value() noexcept { return a; }
constexpr const u64& value() const noexcept { return a; }
constexpr modint operator+(const modint rhs) const noexcept {
return modint(*this) += rhs;
}
constexpr modint operator-(const modint rhs) const noexcept {
return modint(*this) -= rhs;
}
constexpr modint operator*(const modint rhs) const noexcept {
return modint(*this) *= rhs;
}
constexpr modint operator/(const modint rhs) const noexcept {
return modint(*this) /= rhs;
}
constexpr modint& operator+=(const modint rhs) noexcept {
a += rhs.a;
if (a >= Modulus) {
a -= Modulus;
}
return *this;
}
constexpr modint& operator-=(const modint rhs) noexcept {
if (a < rhs.a) {
a += Modulus;
}
a -= rhs.a;
return *this;
}
constexpr modint& operator*=(const modint rhs) noexcept {
a = a * rhs.a % Modulus;
return *this;
}
constexpr modint& operator/=(modint rhs) noexcept {
u64 exp = Modulus - 2;
while (exp) {
if (exp % 2) {
*this *= rhs;
}
rhs *= rhs;
exp /= 2;
}
return *this;
}
};
using mint = modint<MOD>;
int main() {
cin >> n >> p;
vector<mint> A,B;
mint ans = 0,wa=0;
A.push_back(0);
A.push_back(1);
rep(i, n) {
A.push_back(A[i] + A[i + 1] * p);
}
rep(i, n) {
wa += A[i];
}
wa = wa * wa;
wa=wa;
rep(i, n) {
wa += A[i]*A[i];
}
wa = wa / 2;
cout << wa.a << endl;
}
wait_sushi