結果

問題 No.171 スワップ文字列(Med)
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-03-13 23:14:18
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 525 bytes
コンパイル時間 491 ms
コンパイル使用メモリ 56,916 KB
実行使用メモリ 11,364 KB
最終ジャッジ日時 2023-10-26 03:48:24
合計ジャッジ時間 1,142 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
11,292 KB
testcase_01 AC 9 ms
11,292 KB
testcase_02 AC 9 ms
11,360 KB
testcase_03 AC 9 ms
11,356 KB
testcase_04 AC 9 ms
11,356 KB
testcase_05 AC 9 ms
11,364 KB
testcase_06 AC 8 ms
11,360 KB
testcase_07 AC 9 ms
11,360 KB
testcase_08 AC 8 ms
11,364 KB
testcase_09 AC 9 ms
11,364 KB
testcase_10 AC 9 ms
11,292 KB
testcase_11 AC 9 ms
11,292 KB
testcase_12 AC 9 ms
11,356 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>

using namespace std;

#define NMAX 1000

#define mod 573

int main(){

	long long C[NMAX+1][NMAX+1]={{0}};
	for(int i=0;i<=NMAX;i++){
		C[i][0]=1;
		for(int j=1;j<=i;j++){
			C[i][j]=C[i-1][j]+C[i-1][j-1];
			C[i][j]%=mod;
		}
	}

	int cnt[26]={0};
	string S;

	cin>>S;

	int N=S.size();
	for(int i=0;i<S.size();i++) cnt[S[i]-'A']++;

	long long ans=1;

	for(int i=0;i<26;i++){
		ans*=C[N][cnt[i]];
		N-=cnt[i];
		ans%=mod;
	}

	if(ans==0) cout<<"572"<<endl;
	else cout<<ans-1<<endl;
	
}
0