Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss10338 - | Accepted | Python | 1.020 | 0.000 | 4464 | 5 mins ago |
Suggest:
1/ RESULT = ALL CASE - SAME CASE
2/ ALL CASE = n! (n is length string)
3/ SAME CASE = a! * b! * ... * c! (with a,b,c is number of same chars )
from functools import cache
@cache
def fac(n):
if n == 1:
return 1
return fac(n - 1) * n
n = int(input())
for i in range(1, n+1):
s = input()
d = {}
for c in s:
if c not in d:
d[c] = 1
else:
d[c] += 1
r = fac(len(s))
for key in d:
r //= fac(d[key])
print(f'Data set {i}: {r}')
No comments:
Post a Comment