結果
| 問題 |
No.171 スワップ文字列(Med)
|
| コンテスト | |
| ユーザー |
htensai
|
| 提出日時 | 2020-01-15 20:07:49 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 145 ms / 1,000 ms |
| コード長 | 926 bytes |
| コンパイル時間 | 2,274 ms |
| コンパイル使用メモリ | 77,284 KB |
| 実行使用メモリ | 48,040 KB |
| 最終ジャッジ日時 | 2024-06-11 18:27:31 |
| 合計ジャッジ時間 | 4,963 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 10 |
ソースコード
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);
}
}
htensai