結果
| 問題 | No.2593 Reorder and Mod 120 | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2023-12-23 17:35:20 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 50 ms / 2,000 ms | 
| コード長 | 798 bytes | 
| コンパイル時間 | 420 ms | 
| コンパイル使用メモリ | 82,280 KB | 
| 実行使用メモリ | 75,316 KB | 
| 最終ジャッジ日時 | 2024-09-27 12:28:46 | 
| 合計ジャッジ時間 | 2,315 ms | 
| ジャッジサーバーID (参考情報) | judge3 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 26 | 
ソースコード
import sys
N = int(input())
S = input()
dat = [0] * 10
for s in S:
    dat[int(s)] += 1
ans = set()
t = 0
if N == 1:
    print(1)
    exit()
elif N == 2:
    ans.add(int(S))
    ans.add(int(S[1]) * 10 + int(S[0]))
    print(len(ans))
    exit()
    
for i in range(1,10):
    if dat[i]:
        dat[i] -= 1
    else:
        continue
    for j in range(1,10):
        if dat[j]:
            dat[j] -= 1
        else:
            continue
        for k in range(1,10):
            if dat[k]:
                dat[k] -= 1
            else:
                continue
            t = i + 10 * j + 100 * k
            for u in range(1,10):
                t += u * dat[u] * 40
            ans.add(t % 120)
            dat[k] += 1
        dat[j] += 1
    dat[i] += 1
print(len(ans))
                
            
            
            
        