結果

問題 No.2593 Reorder and Mod 120
ユーザー PNJPNJ
提出日時 2024-04-25 12:01:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 65 ms / 2,000 ms
コード長 510 bytes
コンパイル時間 622 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 71,296 KB
最終ジャッジ日時 2024-04-25 12:01:28
合計ジャッジ時間 2,332 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
61,824 KB
testcase_01 AC 37 ms
51,840 KB
testcase_02 AC 47 ms
61,696 KB
testcase_03 AC 46 ms
61,952 KB
testcase_04 AC 47 ms
62,208 KB
testcase_05 AC 48 ms
61,568 KB
testcase_06 AC 46 ms
61,952 KB
testcase_07 AC 36 ms
51,968 KB
testcase_08 AC 35 ms
51,712 KB
testcase_09 AC 36 ms
51,712 KB
testcase_10 AC 37 ms
51,968 KB
testcase_11 AC 49 ms
63,616 KB
testcase_12 AC 51 ms
64,512 KB
testcase_13 AC 58 ms
70,784 KB
testcase_14 AC 53 ms
66,304 KB
testcase_15 AC 65 ms
68,864 KB
testcase_16 AC 51 ms
64,384 KB
testcase_17 AC 54 ms
65,664 KB
testcase_18 AC 61 ms
65,536 KB
testcase_19 AC 59 ms
69,760 KB
testcase_20 AC 58 ms
70,912 KB
testcase_21 AC 57 ms
71,296 KB
testcase_22 AC 56 ms
70,656 KB
testcase_23 AC 57 ms
70,656 KB
testcase_24 AC 55 ms
70,272 KB
testcase_25 AC 55 ms
70,144 KB
testcase_26 AC 56 ms
70,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 120 = 3*5*8
# 下3桁だけで、40で割った余りは決定する。
# 3で割った余りは固定。
# CRT

N = int(input())
S = input()
if N == 1:
  print(1)
  exit()
if N == 2:
  T = S[::-1]
  ans = 2
  if int(S) % 120 == int(T) % 120:
    ans = 1
  print(ans)
  exit()

C = [0 for i in range(10)]
for i in range(N):
  C[int(S[i])] += 1
X = set()
for i in range(100,1000):
  n = str(i)
  CC = C[:]
  for j in range(len(n)):
    CC[int(n[j])] -= 1
  if min(CC) >= 0:
    X.add(i % 40)
print(len(X))
0