結果

問題 No.171 スワップ文字列(Med)
ユーザー htensaihtensai
提出日時 2020-01-15 20:07:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 1,000 ms
コード長 926 bytes
コンパイル時間 2,241 ms
コンパイル使用メモリ 74,180 KB
実行使用メモリ 60,456 KB
最終ジャッジ日時 2023-09-02 11:43:51
合計ジャッジ時間 5,139 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 121 ms
55,996 KB
testcase_01 AC 123 ms
55,612 KB
testcase_02 AC 134 ms
57,516 KB
testcase_03 AC 123 ms
55,612 KB
testcase_04 AC 122 ms
55,568 KB
testcase_05 AC 129 ms
55,700 KB
testcase_06 AC 137 ms
58,088 KB
testcase_07 AC 142 ms
60,188 KB
testcase_08 AC 141 ms
60,456 KB
testcase_09 AC 141 ms
60,072 KB
testcase_10 AC 123 ms
55,564 KB
testcase_11 AC 122 ms
55,584 KB
testcase_12 AC 122 ms
55,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;

public class Main {
    static final int MOD = 573;
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] arr = sc.next().toCharArray();
        int n = arr.length;
        int[][] comb = new int[n + 1][n + 1];
        for (int i = 0; i <= n; i++) {
            for (int j = 0; j <= i; j++) {
                if (j == 0 || j == i) {
                    comb[i][j] = 1;
                } else {
                    comb[i][j] = (comb[i - 1][j] + comb[i - 1][j - 1]) % MOD;
                }
            }
        }
        int[] counts = new int[26];
        for (char c : arr) {
            counts[c - 'A']++;
        }
        int ans = 1;
        for (int x : counts) {
            ans *= comb[n][x];
            ans %= MOD;
            n -= x;
        }
        ans = (ans - 1 + MOD) % MOD;
        System.out.println(ans);
    }
}
0