結果

問題 No.171 スワップ文字列(Med)
ユーザー scachescache
提出日時 2015-05-26 19:38:44
言語 Java19
(openjdk 21)
結果
AC  
実行時間 140 ms / 1,000 ms
コード長 668 bytes
コンパイル時間 2,007 ms
コンパイル使用メモリ 74,572 KB
実行使用メモリ 60,616 KB
最終ジャッジ日時 2023-09-20 13:35:19
合計ジャッジ時間 5,760 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
60,088 KB
testcase_01 AC 132 ms
60,616 KB
testcase_02 AC 137 ms
60,048 KB
testcase_03 AC 134 ms
60,176 KB
testcase_04 AC 134 ms
60,496 KB
testcase_05 AC 137 ms
59,964 KB
testcase_06 AC 140 ms
60,160 KB
testcase_07 AC 139 ms
60,092 KB
testcase_08 AC 139 ms
60,156 KB
testcase_09 AC 136 ms
60,400 KB
testcase_10 AC 137 ms
59,904 KB
testcase_11 AC 136 ms
60,056 KB
testcase_12 AC 136 ms
59,804 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Scanner;

public class Main {

	public static final void main(String[] args) {
		new Main();
	}

	public Main() {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();	
		System.out.println(solve(s));
	}

	int[][] dp;
	private int solve(String s) {
		dp = new int[1001][1001];
		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] + dp[i-1][j-1]) % 573; 
		}
		
		int[] count = new int[26];
		for(char c : s.toCharArray())
			count[c-'A']++;
		
		int res = 1;
		int ct = s.length();
		for(int c : count){
			res = (res*dp[ct][c])%573;
			ct -= c;
		}
		
		res = (res+573-1)%573;
		return res;
	}
}
0