結果

問題 No.170 スワップ文字列(Easy)
ユーザー ronpooronpoo
提出日時 2023-08-23 16:23:20
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 375 bytes
コンパイル時間 259 ms
コンパイル使用メモリ 86,996 KB
実行使用メモリ 71,460 KB
最終ジャッジ日時 2023-08-23 16:23:24
合計ジャッジ時間 3,269 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
71,176 KB
testcase_01 AC 68 ms
71,256 KB
testcase_02 AC 68 ms
71,288 KB
testcase_03 AC 67 ms
71,176 KB
testcase_04 AC 68 ms
71,140 KB
testcase_05 AC 67 ms
71,148 KB
testcase_06 AC 70 ms
71,152 KB
testcase_07 AC 67 ms
71,180 KB
testcase_08 AC 68 ms
71,192 KB
testcase_09 AC 69 ms
71,120 KB
testcase_10 AC 67 ms
71,276 KB
testcase_11 AC 67 ms
70,992 KB
testcase_12 AC 67 ms
71,352 KB
testcase_13 AC 69 ms
71,148 KB
testcase_14 AC 69 ms
71,176 KB
testcase_15 AC 70 ms
71,288 KB
testcase_16 AC 69 ms
71,296 KB
testcase_17 AC 70 ms
71,384 KB
testcase_18 AC 69 ms
71,172 KB
testcase_19 AC 70 ms
71,244 KB
testcase_20 AC 68 ms
71,460 KB
testcase_21 AC 66 ms
71,036 KB
testcase_22 AC 67 ms
71,308 KB
testcase_23 AC 68 ms
71,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

S = input()
L = len(S)

def nCr(n,r):    
    r = min(r, n-r)
    npr=1
    for i in range(n,n-r,-1):
        npr*=i    
    factr =1
    for i in range(r,1,-1):
        factr*=i
    return npr//factr

a = [0] * 26
for s in S:
    i = ord(s) - ord('A')
    a[i] += 1

ans = 1
n = L
for r in a:
    if n == 0:
        break
    ans *= nCr(n, r)
    n -= r

ans -= 1
print(ans)
0