結果
| 問題 | No.1448 和差算 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-05-12 21:28:10 |
| 言語 | Python3 (3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 25 ms / 2,000 ms |
| + 396µs | |
| コード長 | 725 bytes |
| 記録 | |
| コンパイル時間 | 50 ms |
| コンパイル使用メモリ | 14,720 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2026-10-17 11:31:36 |
| 合計ジャッジ時間 | 3,161 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge5_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 37 |
ソースコード
import sys
if len(sys.argv) == 2:
sys.stdin = open(sys.argv[1])
a, b, c, d = map(int, input().split())
n = int(input())
mod = 10**9 + 7
q, r = divmod(n, 8)
ans = -10**18
for x in [a, b]:
for y in [c, d]:
if r == 0:
ans = max(ans, x + y)
elif r == 1:
ans = max(ans, 2 * x)
elif r == 2:
ans = max(ans, 2 * (x - y))
elif r == 3:
ans = max(ans, -4 * y)
elif r == 4:
ans = max(ans, -4 * (x + y))
elif r == 5:
ans = max(ans, -8 * x)
elif r == 6:
ans = max(ans, -8 * (x - y))
else:
ans = max(ans, 16 * y)
ans %= mod
ans *= pow(16, q, mod)
ans %= mod
print(ans)