結果

問題 No.840 ほむほむほむら
ユーザー keymoonkeymoon
提出日時 2019-03-29 15:43:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,027 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 44,516 KB
最終ジャッジ日時 2024-04-24 16:35:37
合計ジャッジ時間 17,527 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 497 ms
44,256 KB
testcase_01 AC 495 ms
44,256 KB
testcase_02 AC 509 ms
44,128 KB
testcase_03 AC 503 ms
44,252 KB
testcase_04 AC 481 ms
44,128 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 488 ms
44,252 KB
testcase_21 AC 475 ms
44,124 KB
testcase_22 AC 487 ms
44,252 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 481 ms
44,136 KB
testcase_26 AC 484 ms
44,256 KB
testcase_27 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np

#誤差死する
n,k = map(int,input().split())
matrix = np.zeros((k**3, k**3), dtype = int)

for i in range(k**3):
	val = i
	aCount = val % k
	val = val // k
	abCount = val % k
	val = val // k
	abcCount = val % k

	#aが追加された時
	newACount = (aCount + 1) % k
	newABCount = abCount
	newABCCount = abcCount
	matrix[i, (newABCCount * k + newABCount) * k + newACount] += 1

	#bが追加された時
	newACount = aCount
	newABCount = (abCount + aCount) % k
	newABCCount = abcCount
	matrix[i, (newABCCount * k + newABCount) * k + newACount] += 1

	#cが追加された時
	newACount = aCount
	newABCount = abCount
	newABCCount = (abcCount + abCount) % k
	matrix[i, (newABCCount * k + newABCount) * k + newACount] += 1

res = np.zeros((1, k**3), dtype = int)
res[0, 0] = 1

mod = 1000000007

while n > 0:
	if n % 2 == 1:
		res = np.mod(np.matmul(res, matrix), mod)
	matrix = np.mod((np.matmul(matrix, matrix)),mod)
	n = n // 2


numRes = 0
for i in range(k**2):
	numRes += res[0, i]

print(numRes % mod)
0