結果
問題 |
No.1275 綺麗な式
|
ユーザー |
![]() |
提出日時 | 2025-09-22 08:13:26 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 17 ms / 2,000 ms |
コード長 | 1,121 bytes |
コンパイル時間 | 1,136 ms |
コンパイル使用メモリ | 128,156 KB |
実行使用メモリ | 7,716 KB |
最終ジャッジ日時 | 2025-09-22 08:13:29 |
合計ジャッジ時間 | 3,579 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 60 |
ソースコード
#include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <cmath> #include <complex> #include <cstdio> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <stack> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef long double ld; typedef pair<ll, ll> P; int a, b; ll n; const int md = (int)1e9 + 7; #define ADD(x, y) (x + y) % md #define MUL(x, y) (x * y) % md P f(P l, P r) { return P(ADD(MUL(l.first, r.first), MUL(MUL(l.second, r.second), b)), ADD(MUL(l.first, r.second), MUL(l.second, r.first))); } P g(P l, ll n) { P t(1, 0); while (n) { if (n & 1) t = f(t, l); l = f(l, l); n >>= 1; } return t; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> a >> b >> n; P s = g(P(a, 1), n); P t = g(P(a, -1), n); ll m = ADD(s.first, t.first); cout << m << "\n"; }