結果
問題 |
No.2593 Reorder and Mod 120
|
ユーザー |
![]() |
提出日時 | 2024-01-04 14:15:04 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 62 ms / 2,000 ms |
コード長 | 562 bytes |
コンパイル時間 | 375 ms |
コンパイル使用メモリ | 82,136 KB |
実行使用メモリ | 76,864 KB |
最終ジャッジ日時 | 2024-09-27 18:45:10 |
合計ジャッジ時間 | 2,808 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 26 |
ソースコード
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))