結果
| 問題 | No.2593 Reorder and Mod 120 | 
| コンテスト | |
| ユーザー |  titia | 
| 提出日時 | 2023-12-21 07:03:38 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 329 ms / 2,000 ms | 
| コード長 | 549 bytes | 
| コンパイル時間 | 158 ms | 
| コンパイル使用メモリ | 82,328 KB | 
| 実行使用メモリ | 83,820 KB | 
| 最終ジャッジ日時 | 2024-09-27 10:47:23 | 
| 合計ジャッジ時間 | 6,083 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 26 | 
ソースコード
from collections import Counter
from copy import deepcopy
N=int(input())
S=input().strip()
C=Counter(S)
Q=[(C,0,0)]
ANS=[0]*120
while Q:
    #print(Q)
    x,keta,mod=Q.pop()
    if keta==5 or max(x.values())==0:
        count=0
        for i in range(10):
            count+=x[str(i)]*int(i)
        ANS[(mod+40*count)%120]=1
        continue
    for i in range(10):
        if x[str(i)]>0:
            x[str(i)]-=1
            Q.append((deepcopy(x),keta+1,(mod+int(i)*(10**keta))%120))
            x[str(i)]+=1
            
print(sum(ANS))
            
            
            
        