結果
| 問題 | No.170 スワップ文字列(Easy) | 
| コンテスト | |
| ユーザー |  kenji_shioya | 
| 提出日時 | 2016-06-17 18:12:38 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 141 ms / 5,000 ms | 
| コード長 | 956 bytes | 
| コンパイル時間 | 4,463 ms | 
| コンパイル使用メモリ | 78,488 KB | 
| 実行使用メモリ | 41,696 KB | 
| 最終ジャッジ日時 | 2024-12-23 00:42:19 | 
| 合計ジャッジ時間 | 7,128 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
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>();
    ArrayList<Character> done = new ArrayList<Character>();
    for(int i = 0; i < str.length(); i++){
      if(done.indexOf(str.charAt(i)) != -1){
        continue;
      }
      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);
        done.add(str.charAt(i));
      }
    }
    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;
  }
}
            
            
            
        