結果

問題 No.170 スワップ文字列(Easy)
ユーザー 古寺いろは古寺いろは
提出日時 2015-03-22 23:36:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 690 bytes
コンパイル時間 520 ms
コンパイル使用メモリ 68,464 KB
実行使用メモリ 7,600 KB
最終ジャッジ日時 2023-09-11 09:33:56
合計ジャッジ時間 1,676 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,384 KB
testcase_01 WA -
testcase_02 AC 5 ms
7,388 KB
testcase_03 AC 5 ms
7,316 KB
testcase_04 AC 5 ms
7,548 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 5 ms
7,316 KB
testcase_08 AC 5 ms
7,452 KB
testcase_09 AC 5 ms
7,264 KB
testcase_10 WA -
testcase_11 AC 5 ms
7,408 KB
testcase_12 AC 5 ms
7,276 KB
testcase_13 AC 5 ms
7,252 KB
testcase_14 AC 5 ms
7,264 KB
testcase_15 AC 5 ms
7,324 KB
testcase_16 AC 5 ms
7,348 KB
testcase_17 AC 5 ms
7,336 KB
testcase_18 AC 5 ms
7,468 KB
testcase_19 AC 5 ms
7,268 KB
testcase_20 AC 5 ms
7,320 KB
testcase_21 AC 5 ms
7,252 KB
testcase_22 AC 5 ms
7,264 KB
testcase_23 AC 5 ms
7,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include<map>

#define mod 5730

using namespace std;

int dp[1001][1001];

void settingC(){
	for (int i = 0; i < 1001; i++)
	{
		dp[i][0] = 1;
		for (int j = 1; j <= i; j++)
		{
			dp[i][j] = dp[i - 1][j - 1] + dp[i - 1][j];
			dp[i][j] %= mod;
		}
	}
}

int main(int argc, char* argv[]) {
	string S;
	cin >> S;
	map<char, int> m;

	settingC();

	for (int i = 0; i < S.size(); i++)
	{
		m[S[i]]++;
	}

	int remain = S.size();
	int ans = 1;

	map<char, int>::iterator it = m.begin();
	while (it != m.end())
	{
		ans *= dp[remain][(*it).second];
		ans %= mod;
		remain -= (*it).second;
		++it;
	}

	ans += mod - 1;
	ans %= mod;
	cout << ans << endl;
}

0