結果
| 問題 | No.171 スワップ文字列(Med) | 
| コンテスト | |
| ユーザー |  yuruhiya | 
| 提出日時 | 2020-05-10 10:26:22 | 
| 言語 | Crystal (1.14.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 437 bytes | 
| コンパイル時間 | 11,522 ms | 
| コンパイル使用メモリ | 295,240 KB | 
| 実行使用メモリ | 7,168 KB | 
| 最終ジャッジ日時 | 2024-06-30 20:08:14 | 
| 合計ジャッジ時間 | 12,571 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 7 WA * 3 | 
ソースコード
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 - 1
            
            
            
        