結果

問題 No.170 スワップ文字列(Easy)
ユーザー scachescache
提出日時 2015-05-26 19:49:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 639 bytes
コンパイル時間 3,404 ms
コンパイル使用メモリ 72,148 KB
実行使用メモリ 56,516 KB
最終ジャッジ日時 2023-08-24 16:19:55
合計ジャッジ時間 7,442 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,728 KB
testcase_01 AC 114 ms
55,544 KB
testcase_02 AC 114 ms
55,624 KB
testcase_03 AC 115 ms
56,260 KB
testcase_04 AC 115 ms
56,116 KB
testcase_05 AC 115 ms
56,484 KB
testcase_06 AC 115 ms
56,156 KB
testcase_07 AC 115 ms
56,396 KB
testcase_08 AC 113 ms
55,708 KB
testcase_09 AC 116 ms
55,996 KB
testcase_10 AC 116 ms
55,636 KB
testcase_11 AC 115 ms
56,240 KB
testcase_12 AC 115 ms
56,516 KB
testcase_13 AC 115 ms
55,532 KB
testcase_14 AC 118 ms
56,032 KB
testcase_15 AC 115 ms
55,868 KB
testcase_16 AC 116 ms
55,396 KB
testcase_17 AC 116 ms
55,532 KB
testcase_18 AC 116 ms
55,368 KB
testcase_19 AC 118 ms
55,416 KB
testcase_20 AC 121 ms
55,796 KB
testcase_21 AC 115 ms
54,108 KB
testcase_22 AC 114 ms
55,532 KB
testcase_23 AC 115 ms
55,352 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[9][9];
		for(int i=0;i<9;i++){
			dp[i][0] = 1;
			for(int j=1;j<=i;j++)
				dp[i][j] = (dp[i-1][j] + dp[i-1][j-1]); 
		}
		
		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]);
			ct -= c;
		}
		
		res--;
		return res;
	}
}
0