結果

問題 No.170 スワップ文字列(Easy)
ユーザー titiatitia
提出日時 2022-04-27 01:34:37
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 133 ms / 5,000 ms
コード長 460 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 24,052 KB
最終ジャッジ日時 2023-09-10 16:29:38
合計ジャッジ時間 4,742 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
24,016 KB
testcase_01 AC 127 ms
23,904 KB
testcase_02 AC 128 ms
23,868 KB
testcase_03 AC 129 ms
23,828 KB
testcase_04 AC 130 ms
24,020 KB
testcase_05 AC 128 ms
24,016 KB
testcase_06 AC 127 ms
23,964 KB
testcase_07 AC 129 ms
23,912 KB
testcase_08 AC 128 ms
23,948 KB
testcase_09 AC 129 ms
23,916 KB
testcase_10 AC 131 ms
23,952 KB
testcase_11 AC 130 ms
24,052 KB
testcase_12 AC 128 ms
23,872 KB
testcase_13 AC 133 ms
23,900 KB
testcase_14 AC 127 ms
23,916 KB
testcase_15 AC 127 ms
23,884 KB
testcase_16 AC 128 ms
23,872 KB
testcase_17 AC 128 ms
23,916 KB
testcase_18 AC 130 ms
23,900 KB
testcase_19 AC 132 ms
23,864 KB
testcase_20 AC 127 ms
23,992 KB
testcase_21 AC 127 ms
23,920 KB
testcase_22 AC 130 ms
24,016 KB
testcase_23 AC 128 ms
23,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter

S=input()

mod=10**9+7

FACT=[1]
for i in range(1,2*10**5+1):
    FACT.append(FACT[-1]*i%mod)

FACT_INV=[pow(FACT[-1],mod-2,mod)]
for i in range(2*10**5,0,-1):
    FACT_INV.append(FACT_INV[-1]*i%mod)

FACT_INV.reverse()

def Combi(a,b):
    if 0<=b<=a:
        return FACT[a]*FACT_INV[b]%mod*FACT_INV[a-b]%mod
    else:
        return 0

C=Counter(S)
ANS=1
n=len(S)
for c in C:
    ANS*=Combi(n,C[c])
    n-=C[c]

print(ANS-1)
0