結果

問題 No.1448 和差算
ユーザー lemonlemon
提出日時 2021-04-01 00:42:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 873 bytes
コンパイル時間 1,089 ms
コンパイル使用メモリ 86,976 KB
実行使用メモリ 79,784 KB
最終ジャッジ日時 2023-08-22 05:34:32
合計ジャッジ時間 5,423 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
75,524 KB
testcase_01 AC 75 ms
71,136 KB
testcase_02 AC 71 ms
71,392 KB
testcase_03 AC 69 ms
71,528 KB
testcase_04 AC 69 ms
71,336 KB
testcase_05 AC 70 ms
71,208 KB
testcase_06 AC 69 ms
71,152 KB
testcase_07 AC 74 ms
71,156 KB
testcase_08 AC 71 ms
71,656 KB
testcase_09 AC 70 ms
71,288 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, math
 
sys.setrecursionlimit(500005)
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a, b, c, d = na()
n = ni()

f = n // 8
e = n % 8

def BiPower(a, b):
    ans = 1
    b = bin(b)[2:]
    for i in range(1, len(b) + 1):
        if b[-1 * i] == '1':
            ans *= pow(a, 2 ** (i - 1))
    return ans



def colc(a, b, c, d, i):
    if i == 0:
        return b + d
    elif i == 1:
        return 2 * b
    elif i == 2:
        return 2 * (b - c)
    elif i == 3:
        return -4 * c
    elif i == 4:
        return -4 * (a + c)
    elif i == 5:
        return -8 * a
    elif i == 6:
        return -8 * (a - d)
    elif i == 7:
        return 16 * d

ans = colc(a, b, c, d, e)

ans = (ans * BiPower(16, f))  % 1000000007

if ans < 0:
    ans += 1000000007

print(ans)
0