結果

問題 No.1595 The Final Digit
ユーザー taiga0629kyoprotaiga0629kyopro
提出日時 2021-07-09 21:45:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 551 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,388 KB
実行使用メモリ 76,204 KB
最終ジャッジ日時 2023-09-14 08:21:29
合計ジャッジ時間 2,681 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,280 KB
testcase_01 AC 69 ms
71,520 KB
testcase_02 AC 68 ms
71,496 KB
testcase_03 AC 70 ms
71,304 KB
testcase_04 AC 73 ms
75,668 KB
testcase_05 AC 74 ms
75,684 KB
testcase_06 AC 77 ms
75,860 KB
testcase_07 AC 74 ms
76,188 KB
testcase_08 AC 71 ms
71,284 KB
testcase_09 AC 70 ms
71,180 KB
testcase_10 AC 70 ms
71,224 KB
testcase_11 AC 69 ms
71,368 KB
testcase_12 AC 71 ms
71,232 KB
testcase_13 AC 70 ms
71,284 KB
testcase_14 AC 77 ms
76,092 KB
testcase_15 AC 77 ms
76,108 KB
testcase_16 AC 77 ms
76,204 KB
testcase_17 AC 71 ms
71,460 KB
testcase_18 AC 73 ms
71,428 KB
testcase_19 AC 78 ms
76,036 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