結果

問題 No.170 スワップ文字列(Easy)
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-17 17:47:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 3,016 ms
コンパイル使用メモリ 75,780 KB
実行使用メモリ 56,132 KB
最終ジャッジ日時 2024-04-17 23:09:52
合計ジャッジ時間 6,788 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 116 ms
54,156 KB
testcase_01 AC 119 ms
54,048 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 118 ms
54,184 KB
testcase_06 AC 122 ms
54,192 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 117 ms
54,236 KB
testcase_11 AC 113 ms
54,208 KB
testcase_12 AC 122 ms
54,352 KB
testcase_13 AC 125 ms
54,288 KB
testcase_14 AC 107 ms
53,984 KB
testcase_15 AC 113 ms
53,704 KB
testcase_16 AC 115 ms
54,124 KB
testcase_17 AC 97 ms
52,708 KB
testcase_18 WA -
testcase_19 AC 123 ms
54,300 KB
testcase_20 AC 114 ms
53,048 KB
testcase_21 WA -
testcase_22 AC 116 ms
53,916 KB
testcase_23 AC 123 ms
54,548 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Exercise93{
  public static void main (String[] args){

    Scanner sc = new Scanner(System.in);

    String str = sc.next();

    int baseR = getRoutes(str.length());

    ArrayList<Integer> s = new ArrayList<Integer>();

    for(int i = 0; i < str.length(); i++){
      int count = 1;
      for (int j = i + 1; j < str.length(); j++){
        if(str.charAt(i) == str.charAt(j)){
          count++;
        }
      }
      if(count > 0){
        s.add(count);
      }
    }
    int sameR = 1;
    for(int i = 0; i < s.size(); i++){
      sameR *= getRoutes(s.get(i));
    }
    System.out.println(baseR / sameR - 1);
  }
  private static int getRoutes(int num){
    int r = 1;
    for (int i = 0; i < num; i++){
      r *= num - i;
    }
    return r;
  }
}
0