結果
問題 | No.1595 The Final Digit |
ユーザー |
![]() |
提出日時 | 2021-07-09 21:30:19 |
言語 | PyPy3 (7.3.8) |
結果 |
AC
|
実行時間 | 91 ms / 2,000 ms |
コード長 | 1,129 bytes |
コンパイル時間 | 268 ms |
使用メモリ | 80,740 KB |
最終ジャッジ日時 | 2023-02-01 22:14:24 |
合計ジャッジ時間 | 3,138 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 75 ms
75,784 KB |
testcase_01 | AC | 77 ms
75,760 KB |
testcase_02 | AC | 79 ms
75,508 KB |
testcase_03 | AC | 78 ms
75,500 KB |
testcase_04 | AC | 85 ms
80,736 KB |
testcase_05 | AC | 84 ms
80,280 KB |
testcase_06 | AC | 91 ms
80,356 KB |
testcase_07 | AC | 90 ms
80,448 KB |
testcase_08 | AC | 77 ms
75,456 KB |
testcase_09 | AC | 77 ms
75,788 KB |
testcase_10 | AC | 77 ms
75,836 KB |
testcase_11 | AC | 77 ms
75,460 KB |
testcase_12 | AC | 77 ms
75,840 KB |
testcase_13 | AC | 80 ms
75,844 KB |
testcase_14 | AC | 89 ms
80,640 KB |
testcase_15 | AC | 87 ms
80,740 KB |
testcase_16 | AC | 88 ms
80,360 KB |
testcase_17 | AC | 76 ms
75,760 KB |
testcase_18 | AC | 75 ms
75,676 KB |
testcase_19 | AC | 90 ms
80,640 KB |
ソースコード
import sys sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) def matrix_multiplication_mod(A,B,p): l = len(A) m = len(B) n = len(B[0]) C = [[0]*n for _ in range(l)] for i in range(l): for j in range(n): C[i][j] = sum((A[i][k]*B[k][j]) % p for k in range(m)) % p return C def matrix_power_mod(A,n,p): l = len(A) C = [[0] * l for _ in range(l)] for i in range(l): C[i][i] = 1 while n > 0: if n % 2 == 1: C = matrix_multiplication_mod(C,A,p) A = matrix_multiplication_mod(A,A,p) n >>= 1 return C p,q,r,K = MI() A = [[1,1,1],[1,0,0],[0,1,0]] X = matrix_power_mod(A,K-3,10) ans = X[0][0]*r+X[0][1]*q+X[0][2]*p ans %= 10 print(ans)