結果

問題 No.1448 和差算
ユーザー rin204
提出日時 2022-01-18 05:06:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 196 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 52,224 KB
最終ジャッジ日時 2024-11-23 13:15:28
合計ジャッジ時間 2,984 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7

a, b, c, d = map(int, input().split())
n = int(input())
times = pow(16, n // 8, MOD)
n %= 8

max_ = -float("inf")
for xx in (a, b):
    for y in (c, d):
        x = xx
        for _ in range(n):
            x, y = x - y, x + y
        max_ = max(max_, x + y)
print(max_ * times % MOD)
0