結果
| 問題 | No.1448 和差算 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2022-05-12 21:28:10 | 
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 30 ms / 2,000 ms | 
| コード長 | 725 bytes | 
| コンパイル時間 | 120 ms | 
| コンパイル使用メモリ | 12,672 KB | 
| 実行使用メモリ | 10,880 KB | 
| 最終ジャッジ日時 | 2024-07-20 15:48:46 | 
| 合計ジャッジ時間 | 2,472 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
ソースコード
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)
            
            
            
        