結果
| 問題 | No.171 スワップ文字列(Med) | 
| コンテスト | |
| ユーザー |  t8m8⛄️ | 
| 提出日時 | 2015-03-30 20:00:38 | 
| 言語 | Java (openjdk 23) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 156 ms / 1,000 ms | 
| コード長 | 1,282 bytes | 
| コンパイル時間 | 3,841 ms | 
| コンパイル使用メモリ | 78,784 KB | 
| 実行使用メモリ | 42,564 KB | 
| 最終ジャッジ日時 | 2024-07-03 22:57:42 | 
| 合計ジャッジ時間 | 6,275 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 10 | 
ソースコード
//No.171 スワップ文字列(Med)
import java.util.*;
import java.io.*;
import java.math.*;
import static java.util.Arrays.*;
import static java.lang.Math.*;
public class No171 {
    
    static final Scanner sc = new Scanner(System.in);
    static final PrintWriter out = new PrintWriter(System.out,false);
    static void solve() {
        String s = sc.next();
        int n = s.length();
        int[] cnt = new int[26];
        for (int i=0; i<n; i++) {
            cnt[s.charAt(i)-'A']++;
        }
        BigInteger[] fact = new BigInteger[n+1];
        fact[1] = BigInteger.ONE;
        for (int i=2; i<=n; i++) {
            fact[i] = fact[i-1].multiply(BigInteger.valueOf(i));
        }
        BigInteger ans = fact[n];
        for (int i=0; i<26; i++) {
            if (cnt[i] > 1) {
                ans = ans.divide(fact[cnt[i]]);
            }
        }
        out.println(ans.subtract(BigInteger.ONE).mod(BigInteger.valueOf(573)));
    }
    public static void main(String[] args) {
        long start = System.currentTimeMillis();
        solve();
        out.flush();
        long end = System.currentTimeMillis();
        //trace(end-start + "ms");
        sc.close();
    }
    static void trace(Object... o) { System.out.println(deepToString(o));}
}
            
            
            
        