結果

問題 No.170 スワップ文字列(Easy)
ユーザー spacia
提出日時 2015-12-30 22:33:40
言語 Java
(openjdk 23)
結果
AC  
実行時間 58 ms / 5,000 ms
コード長 725 bytes
コンパイル時間 2,606 ms
コンパイル使用メモリ 74,208 KB
実行使用メモリ 37,192 KB
最終ジャッジ日時 2024-12-23 00:34:25
合計ジャッジ時間 4,256 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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