結果

問題 No.170 スワップ文字列(Easy)
ユーザー tsunabittsunabit
提出日時 2020-03-10 00:52:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 600 bytes
コンパイル時間 4,292 ms
コンパイル使用メモリ 84,504 KB
実行使用メモリ 55,740 KB
最終ジャッジ日時 2024-04-27 16:45:02
合計ジャッジ時間 7,144 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
52,604 KB
testcase_01 AC 102 ms
52,936 KB
testcase_02 AC 96 ms
52,724 KB
testcase_03 AC 107 ms
53,704 KB
testcase_04 AC 107 ms
53,660 KB
testcase_05 AC 109 ms
53,836 KB
testcase_06 AC 115 ms
53,972 KB
testcase_07 AC 96 ms
52,588 KB
testcase_08 AC 115 ms
55,740 KB
testcase_09 AC 116 ms
54,268 KB
testcase_10 AC 112 ms
53,792 KB
testcase_11 AC 111 ms
53,500 KB
testcase_12 AC 110 ms
53,568 KB
testcase_13 AC 101 ms
52,784 KB
testcase_14 AC 115 ms
53,744 KB
testcase_15 AC 119 ms
54,212 KB
testcase_16 AC 107 ms
53,440 KB
testcase_17 AC 113 ms
54,140 KB
testcase_18 AC 111 ms
53,792 KB
testcase_19 AC 112 ms
53,820 KB
testcase_20 AC 114 ms
53,936 KB
testcase_21 AC 109 ms
53,548 KB
testcase_22 AC 108 ms
53,704 KB
testcase_23 AC 113 ms
54,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No170 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		HashMap<Character, Integer> hm = new HashMap<Character, Integer>();
		for(int i = 0; i < s.length(); i++) {
			if(hm.containsKey(s.charAt(i))) hm.put(s.charAt(i), hm.get(s.charAt(i))+1);
			else hm.put(s.charAt(i), 1);
		}
		int w = 1;
		for(int v : hm.values()) w *= kai(v);
		System.out.println(kai(s.length()) / w - 1);
	}
	public static int kai(int n) {
		if(n == 1) return 1;
		else return n * kai(n-1);
	}
}
0