結果

問題 No.170 スワップ文字列(Easy)
ユーザー Mayimg
提出日時 2018-11-24 14:06:24
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 419 bytes
コンパイル時間 2,065 ms
コンパイル使用メモリ 173,252 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 19:18:24
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int fac(int x)
{
	if(x == 1) return 1;
	return x * fac(x - 1);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	string s; cin >> s;
	map<char, int> mp;
	for(int i = 0; i < s.size(); i++) mp[s[i]]++;
	int ans = fac(s.size());
	for(auto i = mp.begin(); i != mp.end(); i++) {
		ans /= fac(i->second);
	}
	cout << ans - 1 << endl;
	return 0;	
}
0