結果

問題 No.171 スワップ文字列(Med)
ユーザー scachescache
提出日時 2015-05-26 19:37:59
言語 Java21
(openjdk 21)
結果
AC  
実行時間 138 ms / 1,000 ms
コード長 680 bytes
コンパイル時間 4,036 ms
コンパイル使用メモリ 74,328 KB
実行使用メモリ 60,416 KB
最終ジャッジ日時 2023-09-20 13:35:11
合計ジャッジ時間 6,327 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
60,344 KB
testcase_01 AC 133 ms
59,852 KB
testcase_02 AC 136 ms
60,156 KB
testcase_03 AC 133 ms
60,356 KB
testcase_04 AC 133 ms
60,356 KB
testcase_05 AC 137 ms
60,276 KB
testcase_06 AC 138 ms
60,288 KB
testcase_07 AC 138 ms
60,100 KB
testcase_08 AC 135 ms
58,288 KB
testcase_09 AC 138 ms
60,160 KB
testcase_10 AC 133 ms
60,380 KB
testcase_11 AC 135 ms
60,416 KB
testcase_12 AC 136 ms
59,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Scanner;

public class Main0414 {

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

	public Main0414() {
		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