結果

問題 No.1448 和差算
ユーザー soraie_soraie_
提出日時 2021-03-31 15:40:38
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 540 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-12-15 00:44:38
合計ジャッジ時間 2,576 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 36
権限があれば一括ダウンロードができます

ソースコード

diff #

a,b,c,d= map(int,input().split())
n=int(input())
m = 10**9+7
if n & 1:
    k = n - 1
    k //= 2
    t = pow(2,k,m)
    if k % 4 == 0:
        print(t * b * 2 % m)
    elif k % 4 == 1:
        print(t * -2 * c % m)
    elif k % 4 == 2:
        print(t * -2 * a % m)
    else:
        print(t * 2 * d % m)
else:
    n //= 2
    t = pow(2,n,m)
    if n % 4 == 0:
        print(t * (b + d) % m)
    elif n % 4 == 1:
        print(t * (b + -c) % m)
    elif n % 4 == 2:
        print(t * (-a + -c) % m)
    else:
        print(t * (-a + d) % m)
0