結果

問題 No.2593 Reorder and Mod 120
ユーザー eve__fuyukieve__fuyuki
提出日時 2024-01-04 14:15:04
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 562 bytes
コンパイル時間 398 ms
コンパイル使用メモリ 81,572 KB
実行使用メモリ 75,916 KB
最終ジャッジ日時 2024-01-04 14:15:08
合計ジャッジ時間 3,510 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 63 ms
62,232 KB
testcase_03 AC 45 ms
62,236 KB
testcase_04 AC 45 ms
62,236 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 44 ms
62,236 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 36 ms
53,460 KB
testcase_09 AC 35 ms
53,460 KB
testcase_10 AC 36 ms
53,460 KB
testcase_11 AC 48 ms
62,372 KB
testcase_12 AC 48 ms
64,444 KB
testcase_13 AC 54 ms
74,480 KB
testcase_14 AC 50 ms
68,548 KB
testcase_15 AC 52 ms
72,912 KB
testcase_16 AC 48 ms
64,444 KB
testcase_17 AC 50 ms
66,468 KB
testcase_18 AC 50 ms
66,480 KB
testcase_19 AC 54 ms
73,688 KB
testcase_20 AC 58 ms
75,916 KB
testcase_21 AC 58 ms
75,916 KB
testcase_22 AC 65 ms
75,916 KB
testcase_23 AC 58 ms
75,916 KB
testcase_24 AC 51 ms
64,832 KB
testcase_25 AC 51 ms
64,828 KB
testcase_26 AC 50 ms
64,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations
N = int(input())
s = input()

if N <= 5:
    ans = set()
    for p in permutations(s):
        ans.add(int(''.join(p)) % 120)
    print(len(ans))
    exit()
cnt = [0] * 10
for c in s:
    cnt[int(c)] += 1

ok = [False] * 40
for n in range(1000):
    cnt_n = [0] * 10
    tmp = n
    for _ in range(min(N, 3)):
        cnt_n[tmp % 10] += 1
        tmp //= 10

    ok_n = True
    for i in range(10):
        if cnt_n[i] > cnt[i]:
            ok_n = False
            break
    if ok_n:
        ok[n % 40] = True

print(sum(ok))
0