結果

問題 No.170 スワップ文字列(Easy)
ユーザー SSRS
提出日時 2020-11-18 15:54:39
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 405 bytes
コンパイル時間 848 ms
コンパイル使用メモリ 69,588 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-23 09:03:14
合計ジャッジ時間 1,508 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main(){
	string S;
	cin >> S;
	int N = S.size();
	vector<int> fact(N + 1, 1);
	for (int i = 1; i <= N; i++){
		fact[i] = fact[i - 1] * i;
	}
	vector<int> cnt(26, 0);
	for (int i = 0; i < N; i++){
		cnt[S[i] - 'A']++;
	}
	int ans = fact[N];
	for (int i = 0; i < 26; i++){
		ans /= fact[cnt[i]];
	}
	cout << ans - 1 << endl;
}
0