結果

問題 No.1595 The Final Digit
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-07-09 21:45:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 148 ms
コンパイル使用メモリ 82,324 KB
実行使用メモリ 60,956 KB
最終ジャッジ日時 2024-07-01 15:45:25
合計ジャッジ時間 1,660 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,672 KB
testcase_01 AC 37 ms
52,136 KB
testcase_02 AC 41 ms
53,560 KB
testcase_03 AC 40 ms
53,520 KB
testcase_04 AC 43 ms
59,668 KB
testcase_05 AC 42 ms
59,064 KB
testcase_06 AC 45 ms
60,228 KB
testcase_07 AC 45 ms
59,884 KB
testcase_08 AC 38 ms
52,312 KB
testcase_09 AC 38 ms
53,772 KB
testcase_10 AC 37 ms
53,032 KB
testcase_11 AC 38 ms
52,936 KB
testcase_12 AC 37 ms
52,816 KB
testcase_13 AC 37 ms
53,304 KB
testcase_14 AC 43 ms
60,100 KB
testcase_15 AC 44 ms
60,156 KB
testcase_16 AC 44 ms
60,012 KB
testcase_17 AC 37 ms
52,596 KB
testcase_18 AC 37 ms
52,932 KB
testcase_19 AC 44 ms
60,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,q,r,k=map(int,input().split())

x=[[0]*3 for _ in range(3)]
x[0][0]=1
x[0][1]=1
x[0][2]=1
x[1][0]=1
x[2][1]=1

mod=10
def mul(a,b):
    n=len(a)
    res=[[0]*n for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                res[i][j]+=a[i][k]*b[k][j]
                res[i][j]%=mod
    return res
def mpow(a,n):
    if n==1:return a
    res=mpow(a,n//2)
    res=mul(res,res)
    if n%2==1:
        res=mul(res,a)
    return res

x=mpow(x,k-3)

ans=r*x[0][0]+q*x[0][1]+p*x[0][2]
ans%=10
print(ans)
0