結果

問題 No.2593 Reorder and Mod 120
ユーザー lloyzlloyz
提出日時 2023-12-28 20:51:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 598 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 72,464 KB
最終ジャッジ日時 2023-12-28 20:52:01
合計ジャッジ時間 3,069 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 36 ms
53,460 KB
testcase_02 AC 38 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 AC 36 ms
53,460 KB
testcase_06 AC 37 ms
53,460 KB
testcase_07 AC 37 ms
53,460 KB
testcase_08 AC 37 ms
53,460 KB
testcase_09 AC 37 ms
53,460 KB
testcase_10 AC 50 ms
53,460 KB
testcase_11 AC 43 ms
59,732 KB
testcase_12 AC 43 ms
61,836 KB
testcase_13 AC 49 ms
72,436 KB
testcase_14 AC 45 ms
63,884 KB
testcase_15 AC 46 ms
70,304 KB
testcase_16 AC 42 ms
59,728 KB
testcase_17 AC 44 ms
63,884 KB
testcase_18 AC 44 ms
63,884 KB
testcase_19 AC 48 ms
72,412 KB
testcase_20 AC 48 ms
72,464 KB
testcase_21 AC 49 ms
72,464 KB
testcase_22 AC 49 ms
72,464 KB
testcase_23 AC 48 ms
72,464 KB
testcase_24 AC 46 ms
59,968 KB
testcase_25 AC 46 ms
59,968 KB
testcase_26 AC 47 ms
59,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import permutations

n = int(input())
s = input()
if n <= 3:
    ans = set()
    for i in permutations(s):
        ans.add(int(''.join(i)) % 120)
    print(len(ans))
    exit()
A = [0 for _ in range(10)]
for i in s:
    A[int(i)] += 1
ans = set()
for a in range(1, 10):
    for b in range(1, 10):
        for c in range(1, 10):
            A[a] -= 1
            A[b] -= 1
            A[c] -= 1
            if A[a] >= 0 and A[b] >= 0 and A[c] >= 0:
                ans.add((c * 100 + b * 10 + a) % 40)
            A[a] += 1
            A[b] += 1
            A[c] += 1
print(len(ans))
0