結果

問題 No.170 スワップ文字列(Easy)
ユーザー chiho_miyakochiho_miyako
提出日時 2015-04-12 00:19:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 121 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 72,452 KB
実行使用メモリ 56,468 KB
最終ジャッジ日時 2023-08-24 16:16:09
合計ジャッジ時間 6,101 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
55,628 KB
testcase_01 AC 115 ms
55,868 KB
testcase_02 AC 115 ms
55,620 KB
testcase_03 AC 114 ms
55,776 KB
testcase_04 AC 114 ms
55,896 KB
testcase_05 AC 115 ms
55,824 KB
testcase_06 AC 120 ms
55,704 KB
testcase_07 AC 116 ms
55,772 KB
testcase_08 AC 115 ms
55,744 KB
testcase_09 AC 117 ms
55,584 KB
testcase_10 AC 116 ms
55,824 KB
testcase_11 AC 116 ms
55,568 KB
testcase_12 AC 116 ms
55,612 KB
testcase_13 AC 116 ms
55,840 KB
testcase_14 AC 115 ms
55,776 KB
testcase_15 AC 116 ms
55,684 KB
testcase_16 AC 116 ms
56,468 KB
testcase_17 AC 115 ms
55,764 KB
testcase_18 AC 116 ms
55,428 KB
testcase_19 AC 118 ms
56,444 KB
testcase_20 AC 121 ms
55,480 KB
testcase_21 AC 115 ms
55,736 KB
testcase_22 AC 116 ms
55,752 KB
testcase_23 AC 115 ms
55,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner koko = new Scanner(System.in);
        String s = koko.next();
        int n = s.length();
        char[] ss = s.toCharArray();
        Arrays.sort(ss);
        int count = 1;
        int mo = 1;
        int chi = n;
        int rest = n;
        for(int i=1; i<n; i++){
            if(ss[i]==ss[i-1]){
                count = count + 1;
                rest = rest - 1;
            }else{
                count = 1;
                rest = rest-1;
            }
            mo = count*mo;
            chi = chi*rest;
        }
        int ans = chi/mo;
        System.out.println(ans-1);
    }
}
0