結果
問題 | No.1050 Zero (Maximum) |
ユーザー | tktk_snsn |
提出日時 | 2020-12-16 19:10:17 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 115 ms / 2,000 ms |
コード長 | 851 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 81,800 KB |
実行使用メモリ | 75,244 KB |
最終ジャッジ日時 | 2023-10-20 09:47:17 |
合計ジャッジ時間 | 2,495 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
53,364 KB |
testcase_01 | AC | 47 ms
61,856 KB |
testcase_02 | AC | 64 ms
64,088 KB |
testcase_03 | AC | 70 ms
75,244 KB |
testcase_04 | AC | 88 ms
70,356 KB |
testcase_05 | AC | 91 ms
70,356 KB |
testcase_06 | AC | 67 ms
66,260 KB |
testcase_07 | AC | 72 ms
68,308 KB |
testcase_08 | AC | 50 ms
63,920 KB |
testcase_09 | AC | 57 ms
64,016 KB |
testcase_10 | AC | 104 ms
72,404 KB |
testcase_11 | AC | 86 ms
70,356 KB |
testcase_12 | AC | 45 ms
61,716 KB |
testcase_13 | AC | 36 ms
53,364 KB |
testcase_14 | AC | 36 ms
53,364 KB |
testcase_15 | AC | 36 ms
53,364 KB |
testcase_16 | AC | 110 ms
72,404 KB |
testcase_17 | AC | 115 ms
72,732 KB |
ソースコード
def mat_mul(A, B): size = len(A) res = [[0] * size for _ in range(size)] for i in range(size): for k in range(size): for j in range(size): res[i][j] += A[i][k] * B[k][j] res[i][j] %= mod return res def mat_pow(A, n): size = len(A) res = [[0] * size for _ in range(size)] for i in range(size): res[i][i] = 1 while n: if n & 1: res = mat_mul(res, A) A = mat_mul(A, A) n >>= 1 return res mod = 10 ** 9 + 7 M, K = map(int, input().split()) A = [[0] * M for _ in range(M)] # add for n in range(M): # 元の数 for m in range(M): # add m i = (n + m) % M A[n][i] += 1 # mult for a in range(M): for m in range(M): b = a * m % M A[a][b] += 1 ans = mat_pow(A, K)[0][0] print(ans)