結果

問題 No.171 スワップ文字列(Med)
ユーザー たこしたこし
提出日時 2015-06-07 22:16:46
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 1,000 ms
コード長 1,280 bytes
コンパイル時間 760 ms
コンパイル使用メモリ 98,436 KB
実行使用メモリ 7,536 KB
最終ジャッジ日時 2023-09-20 19:40:42
合計ジャッジ時間 1,627 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
7,272 KB
testcase_01 AC 5 ms
7,464 KB
testcase_02 AC 6 ms
7,252 KB
testcase_03 AC 6 ms
7,320 KB
testcase_04 AC 5 ms
7,384 KB
testcase_05 AC 6 ms
7,264 KB
testcase_06 AC 5 ms
7,268 KB
testcase_07 AC 6 ms
7,272 KB
testcase_08 AC 6 ms
7,536 KB
testcase_09 AC 6 ms
7,276 KB
testcase_10 AC 6 ms
7,268 KB
testcase_11 AC 6 ms
7,324 KB
testcase_12 AC 6 ms
7,312 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <queue>
#include <complex>

#define INF 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long

using namespace std;

#define mod 573
#define MAX_C 1001

int C[MAX_C][MAX_C];

void init(){

	C[0][0] = 1;
	for (int i = 1; i < MAX_C; i++){
		for (int j = 0; j <= i; j++){
			if (j == 0 || j == i){
				C[i][j] = C[i - 1][0];
			}
			else{
				C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
			}
		}
	}

}

string S;
map<char, int> M;

int main() {

	init();
	
	cin >> S;
	
	for (int i = 0; i < S.length(); i++){
		M[S[i]]++;
	}

	int N = S.length();
	int ans = 1;

	for (char c = 'A'; c <= 'Z'; c++){
		
		if (N == 0)
			break;

		ans = (ans * C[N][M[c]]) % mod;
		N -= M[c];

	}

	if (ans == 0)
		ans = 573;

	cout << (ans-1) % mod << endl;

	return 0;
}
0