結果

問題 No.170 スワップ文字列(Easy)
ユーザー spaciaspacia
提出日時 2015-12-30 22:33:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 44 ms / 5,000 ms
コード長 725 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 72,292 KB
実行使用メモリ 49,612 KB
最終ジャッジ日時 2023-08-24 16:25:32
合計ジャッジ時間 4,237 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
49,144 KB
testcase_01 AC 43 ms
49,528 KB
testcase_02 AC 42 ms
49,152 KB
testcase_03 AC 43 ms
49,264 KB
testcase_04 AC 43 ms
49,392 KB
testcase_05 AC 42 ms
49,368 KB
testcase_06 AC 41 ms
49,304 KB
testcase_07 AC 43 ms
49,272 KB
testcase_08 AC 42 ms
49,264 KB
testcase_09 AC 42 ms
49,232 KB
testcase_10 AC 42 ms
49,088 KB
testcase_11 AC 42 ms
49,316 KB
testcase_12 AC 43 ms
49,228 KB
testcase_13 AC 42 ms
47,340 KB
testcase_14 AC 42 ms
49,324 KB
testcase_15 AC 43 ms
49,268 KB
testcase_16 AC 42 ms
49,304 KB
testcase_17 AC 42 ms
49,312 KB
testcase_18 AC 42 ms
49,428 KB
testcase_19 AC 42 ms
49,340 KB
testcase_20 AC 42 ms
49,612 KB
testcase_21 AC 42 ms
49,288 KB
testcase_22 AC 42 ms
49,388 KB
testcase_23 AC 42 ms
49,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main170 {
	
	public static int comb (int n , int m) {
		int[] fact = {1,1,2,6,24,120,720,5040,40320};
		return fact[n] / (fact[m] * fact[n - m]);
	}
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		int ans = 1;
		int len = s.length();
		int[] seq = new int[26];
		
		for (int i = 0; i < len; i++) {
			seq[(int)s.charAt(i) - 65]++;
		}
		for (int i = 0; i < seq.length; i++) {
			if (seq[i] == 0) continue;
			ans *= comb(len , seq[i]);
			len -= seq[i];
		}
		
		out(ans - 1);
		
	}
}
0