結果

問題 No.170 スワップ文字列(Easy)
コンテスト
ユーザー chiho_miyako
提出日時 2015-04-12 00:19:48
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 57 ms / 5,000 ms
コード長 714 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,914 ms
コンパイル使用メモリ 86,372 KB
実行使用メモリ 41,692 KB
最終ジャッジ日時 2026-05-29 03:18:26
合計ジャッジ時間 4,467 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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