結果

問題 No.171 スワップ文字列(Med)
ユーザー TwizzTwizz
提出日時 2017-05-17 10:14:59
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 600 bytes
コンパイル時間 1,324 ms
コンパイル使用メモリ 159,764 KB
実行使用メモリ 12,048 KB
最終ジャッジ日時 2023-10-17 14:40:42
合計ジャッジ時間 5,889 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
typedef long long ll;
const ll mod = 537;

string s;

int main() {
	cin >> s;

	ll count[26] = {};
	ll n= s.size();
	ll c[105][105] = {};

	rep(i, 1, 1002) {
		rep(j, 0, i+1) {
			c[i][j] = (j == 0 || j == 1) ? 1 : (c[i - 1][j - 1] + c[i - 1][j]) % mod;
		}
	}

	rep(i, 0, n) {
		count[s[i] - 'A']++;
	}
	
	ll ret = 1;

	rep(i, 0, 26) {
		ret = ret*c[n][count[i]] % mod;
		n -= count[i];
	}
	
	if (ret == 0) { print(0); }
	else print(ret - 1);
	return 0;
}
0