結果

問題 No.1448 和差算
ユーザー rlangevinrlangevin
提出日時 2023-01-01 22:29:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 428 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 82,188 KB
実行使用メモリ 54,216 KB
最終ジャッジ日時 2024-11-27 00:23:14
合計ジャッジ時間 3,049 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 29 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(N, x, y):
    q, r = divmod(N, 4)
    v = pow(-4, q, mod)
    if r == 0:
        return v * x % mod
    elif r == 1:
        return v * 2 * x % mod
    elif r == 2:
        return v * 2 * (x - y) % mod
    else:
        return v * (-4) * y % mod

A, B, C, D = map(int, input().split())
N = int(input())
mod = 10 ** 9 + 7
ans = f(N, A, C)
q, r = divmod(N, 4)
if q % 2 == 0:
    print(f(N, B, C))
else:
    print(f(N, A, D))
0