結果

問題 No.171 スワップ文字列(Med)
ユーザー scachescache
提出日時 2015-05-26 19:40:26
言語 Java19
(openjdk 21)
結果
AC  
実行時間 141 ms / 1,000 ms
コード長 671 bytes
コンパイル時間 3,546 ms
コンパイル使用メモリ 74,104 KB
実行使用メモリ 60,424 KB
最終ジャッジ日時 2023-09-20 13:36:00
合計ジャッジ時間 6,208 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
60,196 KB
testcase_01 AC 138 ms
60,168 KB
testcase_02 AC 139 ms
60,144 KB
testcase_03 AC 135 ms
59,912 KB
testcase_04 AC 136 ms
60,232 KB
testcase_05 AC 141 ms
60,256 KB
testcase_06 AC 138 ms
60,120 KB
testcase_07 AC 140 ms
60,424 KB
testcase_08 AC 140 ms
60,184 KB
testcase_09 AC 141 ms
60,200 KB
testcase_10 AC 136 ms
60,300 KB
testcase_11 AC 138 ms
60,160 KB
testcase_12 AC 140 ms
60,420 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import java.util.Scanner;

public class main1 {

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

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