結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
60,276 KB
testcase_01 AC 135 ms
60,296 KB
testcase_02 AC 138 ms
60,080 KB
testcase_03 AC 136 ms
59,784 KB
testcase_04 AC 139 ms
60,152 KB
testcase_05 AC 138 ms
60,192 KB
testcase_06 AC 139 ms
60,236 KB
testcase_07 AC 139 ms
60,268 KB
testcase_08 AC 138 ms
60,176 KB
testcase_09 AC 139 ms
60,592 KB
testcase_10 AC 137 ms
60,036 KB
testcase_11 AC 135 ms
60,108 KB
testcase_12 AC 135 ms
60,216 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