結果

問題 No.171 スワップ文字列(Med)
ユーザー yuruhiyayuruhiya
提出日時 2020-05-10 10:29:09
言語 Crystal
(1.11.2)
結果
AC  
実行時間 19 ms / 1,000 ms
コード長 451 bytes
コンパイル時間 17,530 ms
コンパイル使用メモリ 254,488 KB
実行使用メモリ 8,812 KB
最終ジャッジ日時 2023-09-13 10:34:06
合計ジャッジ時間 18,010 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,356 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 8 ms
6,964 KB
testcase_03 AC 3 ms
4,520 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 4 ms
5,368 KB
testcase_06 AC 11 ms
7,688 KB
testcase_07 AC 17 ms
8,528 KB
testcase_08 AC 19 ms
8,812 KB
testcase_09 AC 17 ms
8,748 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 AC 2 ms
4,428 KB
testcase_12 AC 3 ms
4,436 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 573

def calc_combination(n)
  res = Array.new(n + 1) { Array.new(n + 1, 1) }
  2.upto(n) do |i|
    1.upto(i - 1) do |j|
      res[i][j] = res[i-1][j-1] + res[i-1][j] % MOD
      res[j][i] = res[i][j]
    end
  end
  res
end

s = read_line
comb = calc_combination(s.size)
cnt = Array.new(26, 0)
s.each_char do |c|
  cnt[c - 'A'] += 1
end

m = s.size
ans = 1
cnt.each do |i|
  ans = ans * comb[m][i] % MOD
  m -= i
end
puts (ans + MOD - 1) % MOD
0