結果

問題 No.171 スワップ文字列(Med)
ユーザー Div9851Div9851
提出日時 2015-03-22 23:45:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 9 ms / 1,000 ms
コード長 491 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 26,456 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2023-09-11 09:35:55
合計ジャッジ時間 966 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,952 KB
testcase_01 AC 9 ms
6,932 KB
testcase_02 AC 8 ms
6,944 KB
testcase_03 AC 9 ms
6,824 KB
testcase_04 AC 9 ms
6,876 KB
testcase_05 AC 8 ms
6,736 KB
testcase_06 AC 8 ms
6,804 KB
testcase_07 AC 9 ms
6,880 KB
testcase_08 AC 8 ms
6,876 KB
testcase_09 AC 8 ms
6,796 KB
testcase_10 AC 8 ms
6,884 KB
testcase_11 AC 8 ms
6,924 KB
testcase_12 AC 8 ms
6,932 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
using namespace std;
int comb[1001][1001];
char S[1001];
int ch[26];
int main() {
	comb[0][0]=1;
	for(int i=0;i<1000;i++) {
		for(int j=0;j<=i;j++) {
			comb[i+1][j]=(comb[i+1][j]+comb[i][j])%573;
			comb[i+1][j+1]=(comb[i+1][j+1]+comb[i][j])%573;
		}
	}
	scanf("%s",S);
	int ans=1,len=0;
	for(int i=0;S[i]!='\0';i++) len++,ch[S[i]-'A']++;
	for(int i=0;i<26;i++) {
		ans=(ans*comb[len][ch[i]])%573;
		len-=ch[i];
	}
	if(ans==0) printf("572\n"); else printf("%d\n",ans-1);
}
0