結果
問題 | No.1448 和差算 |
ユーザー |
|
提出日時 | 2021-03-31 16:15:23 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 738 bytes |
コンパイル時間 | 621 ms |
コンパイル使用メモリ | 70,712 KB |
最終ジャッジ日時 | 2025-01-20 02:03:58 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 36 |
ソースコード
#line 1 "main.cpp"#include <atcoder/modint>#include <iostream>using namespace std;using lint = long long;using mint = atcoder::modint1000000007;void solve() {int a, b, c, d;lint n;cin >> a >> b >> c >> d >> n;mint a0, b0;if (n % 8 < 4) {a0 = b;} else {a0 = a;}if (n % 8 < 2 || 6 <= n % 8) {b0 = d;} else {b0 = c;}a0 *= mint(-4).pow(n / 4);b0 *= mint(-4).pow(n / 4);n %= 4;while (n--) {auto a1 = a0 - b0,b1 = a0 + b0;swap(a0, a1), swap(b0, b1);}cout << (a0 + b0).val() << "\n";}int main() {cin.tie(nullptr);ios::sync_with_stdio(false);solve();return 0;}