結果

問題 No.171 スワップ文字列(Med)
ユーザー t8m8⛄️t8m8⛄️
提出日時 2015-03-30 20:00:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 153 ms / 1,000 ms
コード長 1,282 bytes
コンパイル時間 3,608 ms
コンパイル使用メモリ 75,524 KB
実行使用メモリ 56,600 KB
最終ジャッジ日時 2023-09-17 00:31:06
合計ジャッジ時間 5,771 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 113 ms
55,788 KB
testcase_01 AC 117 ms
55,804 KB
testcase_02 AC 122 ms
55,444 KB
testcase_03 AC 119 ms
55,388 KB
testcase_04 AC 117 ms
55,684 KB
testcase_05 AC 126 ms
56,076 KB
testcase_06 AC 151 ms
56,100 KB
testcase_07 AC 153 ms
56,600 KB
testcase_08 AC 149 ms
55,476 KB
testcase_09 AC 150 ms
56,076 KB
testcase_10 AC 114 ms
56,284 KB
testcase_11 AC 118 ms
55,812 KB
testcase_12 AC 118 ms
55,780 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//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));}
}
0