結果

問題 No.1448 和差算
ユーザー 小野寺健
提出日時 2021-05-01 21:27:43
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 424 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 12,288 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-07-20 04:42:29
合計ジャッジ時間 2,469 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 31 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

def modpow(a, n, m):
    res = 1
    while n > 0:
        if (n & 1) != 0:
            res = res * a % m
        a = a * a % m
        n >>= 1
    return res

A, B, C, D = map(int, input().split())
N = int(input())

M = 10**9+7

p = (N-1) % 8
n = (N-1) // 8

F = [2 * B, 2 * (B - C), -4 * C, -4 * (A + C), -8 * A, -8 * (A - D), 16 * D, 6 * (B + D)]

V = F[p]
    
V = (V + M) % M
V = (V * modpow(16, n, M)) % M
    
print(V)
0