結果
| 問題 | No.1275 綺麗な式 |
| コンテスト | |
| ユーザー |
trineutron
|
| 提出日時 | 2020-10-31 09:55:51 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 751 bytes |
| 記録 | |
| コンパイル時間 | 1,903 ms |
| コンパイル使用メモリ | 210,160 KB |
| 実行使用メモリ | 6,400 KB |
| 最終ジャッジ日時 | 2026-06-14 22:15:55 |
| 合計ジャッジ時間 | 2,940 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 60 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t mod = 1000000007;
class PairInt {
public:
int64_t x, y, z;
PairInt(int64_t a, int64_t b, int64_t c) {
x = a;
y = b;
z = c;
}
PairInt mul(PairInt a, PairInt b) {
return PairInt{(a.x*b.x%mod + a.y*b.y%mod*a.z) % mod, (a.y*b.x%mod + a.x*b.y) % mod, a.z};
}
PairInt power(int64_t n) {
PairInt res(1, 0, this->z);
while (n) {
if (n % 2) res = mul(res, *this);
*this = mul(*this, *this);
n /= 2;
}
return res;
}
};
int main() {
int64_t a, b, n;
cin >> a >> b >> n;
PairInt z(a, 1, b);
cout << z.power(n).x * 2 % mod << endl;
}
trineutron