結果

問題 No.170 スワップ文字列(Easy)
ユーザー tentententen
提出日時 2020-10-15 09:00:13
言語 Java19
(openjdk 21)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 523 bytes
コンパイル時間 1,705 ms
コンパイル使用メモリ 72,824 KB
実行使用メモリ 56,548 KB
最終ジャッジ日時 2023-09-28 01:06:53
合計ジャッジ時間 5,647 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
55,352 KB
testcase_01 AC 107 ms
55,548 KB
testcase_02 AC 104 ms
55,900 KB
testcase_03 AC 111 ms
55,752 KB
testcase_04 AC 104 ms
55,748 KB
testcase_05 AC 101 ms
55,596 KB
testcase_06 AC 101 ms
55,288 KB
testcase_07 AC 101 ms
55,616 KB
testcase_08 AC 105 ms
55,560 KB
testcase_09 AC 104 ms
55,676 KB
testcase_10 AC 105 ms
55,604 KB
testcase_11 AC 101 ms
55,876 KB
testcase_12 AC 103 ms
55,444 KB
testcase_13 AC 101 ms
55,840 KB
testcase_14 AC 99 ms
55,556 KB
testcase_15 AC 104 ms
55,536 KB
testcase_16 AC 106 ms
56,548 KB
testcase_17 AC 107 ms
55,216 KB
testcase_18 AC 103 ms
55,688 KB
testcase_19 AC 100 ms
55,288 KB
testcase_20 AC 102 ms
55,748 KB
testcase_21 AC 105 ms
55,928 KB
testcase_22 AC 105 ms
55,600 KB
testcase_23 AC 103 ms
55,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
    	Scanner sc = new Scanner(System.in);
    	char[] arr = sc.next().toCharArray();
    	int[] counts = new int[26];
    	for (char c : arr) {
    	    counts[c - 'A']++;
    	}
    	long ans = kaijo(arr.length);
    	for (int x : counts) {
    	    ans /= kaijo(x);
    	}
    	System.out.println(ans - 1);
	}
	
	static long kaijo(int x) {
	    if (x == 0) {
	        return 1;
	    } else {
	        return x * kaijo(x - 1);
	    }
	}
}
0