結果

問題 No.170 スワップ文字列(Easy)
ユーザー hhgfhn1hhgfhn1
提出日時 2018-10-19 12:34:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 5,000 ms
コード長 681 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 76,852 KB
実行使用メモリ 54,088 KB
最終ジャッジ日時 2024-04-28 13:14:46
合計ジャッジ時間 6,335 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
53,764 KB
testcase_01 AC 132 ms
53,556 KB
testcase_02 AC 128 ms
53,756 KB
testcase_03 AC 130 ms
54,088 KB
testcase_04 AC 112 ms
52,508 KB
testcase_05 AC 128 ms
41,436 KB
testcase_06 AC 130 ms
41,428 KB
testcase_07 AC 125 ms
41,160 KB
testcase_08 AC 129 ms
41,340 KB
testcase_09 AC 112 ms
40,060 KB
testcase_10 AC 128 ms
41,384 KB
testcase_11 AC 125 ms
41,624 KB
testcase_12 AC 125 ms
41,516 KB
testcase_13 AC 129 ms
41,632 KB
testcase_14 AC 122 ms
41,284 KB
testcase_15 AC 123 ms
41,516 KB
testcase_16 AC 125 ms
40,936 KB
testcase_17 AC 115 ms
40,236 KB
testcase_18 AC 127 ms
41,256 KB
testcase_19 AC 128 ms
41,408 KB
testcase_20 AC 128 ms
41,692 KB
testcase_21 AC 126 ms
41,232 KB
testcase_22 AC 126 ms
41,248 KB
testcase_23 AC 128 ms
41,404 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s=scanner.next();
		Map<String ,Integer>map=new HashMap<>();
		for(int i=0;i<s.length();i++){
			String key=s.substring(i, i+1);
			if (map.containsKey(key)) {
				map.put(key, map.get(key) + 1);
			} else {
				map.put(key, 1);
			}
		}
		long ans=kaijo(s.length());
		for(int val:map.values()){
			ans/=kaijo(val);
		}
		System.out.println(ans-1);
	
	}
	
	static long kaijo(int n){
		long s = 1;
		for (int i = 1; i <= n; i++)
			s *= i;
			return s;
	}
}

0