結果

問題 No.171 スワップ文字列(Med)
ユーザー scachescache
提出日時 2015-05-26 19:42:45
言語 Java21
(openjdk 21)
結果
AC  
実行時間 146 ms / 1,000 ms
コード長 675 bytes
コンパイル時間 3,435 ms
コンパイル使用メモリ 74,636 KB
実行使用メモリ 60,460 KB
最終ジャッジ日時 2023-09-20 13:36:43
合計ジャッジ時間 6,157 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 134 ms
60,156 KB
testcase_01 AC 134 ms
59,944 KB
testcase_02 AC 146 ms
60,112 KB
testcase_03 AC 144 ms
60,360 KB
testcase_04 AC 144 ms
60,180 KB
testcase_05 AC 139 ms
60,172 KB
testcase_06 AC 142 ms
60,260 KB
testcase_07 AC 138 ms
59,896 KB
testcase_08 AC 140 ms
60,180 KB
testcase_09 AC 141 ms
60,360 KB
testcase_10 AC 135 ms
60,348 KB
testcase_11 AC 135 ms
60,184 KB
testcase_12 AC 136 ms
60,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Scanner;

public class Main0414 {

	public static  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