結果

問題 No.170 スワップ文字列(Easy)
ユーザー chiho_miyako
提出日時 2015-04-12 00:19:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 2,507 ms
コンパイル使用メモリ 74,996 KB
実行使用メモリ 41,736 KB
最終ジャッジ日時 2024-12-23 00:25:02
合計ジャッジ時間 6,851 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

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