結果

問題 No.171 スワップ文字列(Med)
ユーザー zangezange
提出日時 2015-03-23 00:12:20
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 602 bytes
コンパイル時間 414 ms
コンパイル使用メモリ 53,820 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-11 09:39:52
合計ジャッジ時間 1,645 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 RE -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 WA -
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
using namespace std;

#define MOD 573

void count(string S, int countList[26]) {
	int n = S.size();
	for (int j = 0; j < n; j++) {
		for (int i = 0; i < 26; i++) {
			if (S[j] == (char)(i+'A')) countList[i]++;
		}
	}
}

int main() {
	string S;
	cin >> S;
	int ans;
	int countList[26] = {};

	int fact[1001];
	fact[0] = 1;
	for (int i = 1; i < 1000; i++) {
		fact[i] = (fact[i-1] * i) % MOD;
	}

	count(S, countList);

	ans = fact[S.size()];
	for (int i = 0; i < 26; i++) {
		ans /= fact[countList[i]];
		ans %= MOD;
	}
	ans--;

	cout << ans << endl;

	return 0;
}
0