結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー sotanishysotanishy
提出日時 2021-07-30 22:03:59
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 581 bytes
コンパイル時間 303 ms
コンパイル使用メモリ 86,928 KB
実行使用メモリ 103,512 KB
最終ジャッジ日時 2023-10-14 04:52:09
合計ジャッジ時間 6,853 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
80,212 KB
testcase_01 AC 93 ms
71,600 KB
testcase_02 AC 97 ms
76,200 KB
testcase_03 AC 241 ms
78,516 KB
testcase_04 AC 93 ms
71,624 KB
testcase_05 AC 91 ms
71,524 KB
testcase_06 AC 93 ms
71,532 KB
testcase_07 AC 100 ms
76,260 KB
testcase_08 AC 105 ms
77,536 KB
testcase_09 AC 157 ms
77,484 KB
testcase_10 AC 105 ms
77,232 KB
testcase_11 AC 120 ms
77,528 KB
testcase_12 AC 114 ms
77,264 KB
testcase_13 AC 104 ms
77,172 KB
testcase_14 TLE -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.readline

N, K = map(int, input().split())
c = [0] + list(map(int, input().split()))
cnt = {}
cnt[tuple(c)] = [1] + [0] * (K-1)
que = deque()
que.append(tuple(c))
while que:
    v = que.popleft()
    for i in range(1, 10):
        if v[i] == 0:
            continue
        u = list(v)
        u[i] -= 1
        u = tuple(u)
        if u not in cnt:
            cnt[u] = [0] * K
            que.append(u)
        for r in range(K):
            n = (10 * r + i) % K
            cnt[u][n] += cnt[v][r]
print(cnt[(0,)*10][0])
0