結果

問題 No.171 スワップ文字列(Med)
ユーザー motimoti
提出日時 2015-04-09 10:30:09
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 5 ms / 1,000 ms
コード長 648 bytes
コンパイル時間 1,244 ms
コンパイル使用メモリ 145,452 KB
実行使用メモリ 10,556 KB
最終ジャッジ日時 2023-09-17 18:58:29
合計ジャッジ時間 2,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,312 KB
testcase_01 AC 5 ms
10,492 KB
testcase_02 AC 5 ms
10,384 KB
testcase_03 AC 5 ms
10,380 KB
testcase_04 AC 5 ms
10,452 KB
testcase_05 AC 5 ms
10,344 KB
testcase_06 AC 5 ms
10,348 KB
testcase_07 AC 5 ms
10,436 KB
testcase_08 AC 5 ms
10,408 KB
testcase_09 AC 5 ms
10,556 KB
testcase_10 AC 5 ms
10,344 KB
testcase_11 AC 5 ms
10,312 KB
testcase_12 AC 5 ms
10,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)

typedef long long ll;

int const MOD = 573;

ll comb[1010][1010];
void make_comb(int n) {
	rep(i, n+1) {
        comb[i][0] = 1;
        REP(j, 1, i+1) {
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
            comb[i][j] %= MOD;
        }
    }
}

int main() {
	make_comb(1005);
	string s; cin >> s;
	int sz = s.size();
	int mp[26]={};
	rep(i, sz) { mp[s[i]-'A']++; }
	ll ans = 1;
	rep(i, 26) {
		if(mp[i]) {
			(ans *= comb[sz][mp[i]])%=MOD;
			sz -= mp[i];
		}
	}

	cout << (ans-1+MOD)%MOD << endl;

	return 0;
}
0