結果
| 問題 |
No.3178 free sort
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-06-15 15:36:14 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 110 ms / 2,000 ms |
| コード長 | 975 bytes |
| コンパイル時間 | 416 ms |
| コンパイル使用メモリ | 81,932 KB |
| 実行使用メモリ | 92,712 KB |
| 最終ジャッジ日時 | 2025-06-15 15:36:22 |
| 合計ジャッジ時間 | 6,804 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 40 |
ソースコード
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush, nlargest, nsmallest
from bisect import bisect_left, bisect, bisect_right
from copy import deepcopy
from time import perf_counter
import sys
from typing import Any, List, Callable
def debug(*args, sep=" ", end="\n") -> None:
print(*args, sep=sep, end=end, file=sys.stderr)
def main():
global inf, MOD
input = sys.stdin.read().split()
ptr = 0
inf = float("inf")
MOD = 998244353
N = input[ptr]; ptr += 1
d = Counter(N)
L = len(N)
f = [1]
for i in range(L):
f.append(f[-1] * (i + 1)); f[-1] %= MOD
ans = f[L]
for i in range(10):
ans *= pow(f[d[str(i)]], -1, mod=MOD); ans %= MOD
if d['0'] > 0:
alt = f[L - 1]
for i in range(10):
alt *= pow(f[d[str(i)] - (i == 0)], -1, mod=MOD); alt %= MOD
ans -= alt; ans %= MOD
print(ans)
if __name__ == "__main__":
main()