結果

問題 No.1631 Sorting Integers (Multiple of K) Easy
ユーザー tcltktcltk
提出日時 2021-09-11 02:59:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,474 ms / 3,000 ms
コード長 899 bytes
コンパイル時間 1,215 ms
コンパイル使用メモリ 86,292 KB
実行使用メモリ 212,772 KB
最終ジャッジ日時 2023-09-03 22:32:56
合計ジャッジ時間 32,219 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 199 ms
80,348 KB
testcase_01 AC 198 ms
80,676 KB
testcase_02 AC 197 ms
80,476 KB
testcase_03 AC 227 ms
83,860 KB
testcase_04 AC 204 ms
80,548 KB
testcase_05 AC 203 ms
80,680 KB
testcase_06 AC 204 ms
80,460 KB
testcase_07 AC 205 ms
80,972 KB
testcase_08 AC 207 ms
81,204 KB
testcase_09 AC 220 ms
84,192 KB
testcase_10 AC 214 ms
83,588 KB
testcase_11 AC 217 ms
83,832 KB
testcase_12 AC 214 ms
83,488 KB
testcase_13 AC 216 ms
83,660 KB
testcase_14 AC 1,645 ms
206,576 KB
testcase_15 AC 2,444 ms
212,772 KB
testcase_16 AC 2,434 ms
212,552 KB
testcase_17 AC 2,474 ms
212,680 KB
testcase_18 AC 2,433 ms
212,548 KB
testcase_19 AC 2,463 ms
212,460 KB
testcase_20 AC 575 ms
212,512 KB
testcase_21 AC 651 ms
196,896 KB
testcase_22 AC 742 ms
210,140 KB
testcase_23 AC 1,383 ms
210,328 KB
testcase_24 AC 1,080 ms
210,248 KB
testcase_25 AC 966 ms
208,936 KB
testcase_26 AC 216 ms
84,672 KB
testcase_27 AC 1,789 ms
176,720 KB
testcase_28 AC 969 ms
123,340 KB
testcase_29 AC 894 ms
123,880 KB
testcase_30 AC 1,250 ms
142,432 KB
testcase_31 AC 1,785 ms
176,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env python3
# from typing import *

import sys
import io
import math
import collections
import decimal
import itertools
import bisect
import heapq


def input():
    return sys.stdin.readline()[:-1]


# sys.setrecursionlimit(1000000)

# _INPUT = """3 2
# 1 2 0 0 0 0 0 0 0
# """
# sys.stdin = io.StringIO(_INPUT)

INF = 10**10


N, K = map(int, input().split())
C = list(map(int, input().split()))

A = []
for i in range(9):
    A += [i+1] * C[i]

dp = [[0] * K for _ in range(1<<N)]
dp[0][0] = 1
for mask in range(1<<N):
    for r in range(K):
        if dp[mask][r] == 0:
            continue
        for i in range(N):
            if mask & (1<<i):
                continue
            mask1 = mask | (1<<i)
            r1 = (10*r+A[i]) % K
            dp[mask1][r1] += dp[mask][r]


ans = dp[(1<<N)-1][0]
for i in range(9):
    for k in range(1, C[i]+1):
        ans //= k
print(ans)
0