結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-10-21 18:39:41 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 32 ms / 5,000 ms |
| コード長 | 485 bytes |
| コンパイル時間 | 158 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 10,752 KB |
| 最終ジャッジ日時 | 2024-07-01 04:14:00 |
| 合計ジャッジ時間 | 1,827 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
ソースコード
from collections import Counter
from math import factorial
def calc_combination(all_: int, partial_: int) -> int:
return factorial(all_) // (factorial(partial_) * factorial(all_ - partial_))
def main():
S = input()
s_counter = Counter(S)
rest = s_counter.total()
patterns = 1
for _, count_ in s_counter.most_common():
patterns *= calc_combination(rest, count_)
rest -= count_
print(patterns - 1)
if __name__ == "__main__":
main()