結果
問題 | No.1927 AB-CD |
ユーザー |
![]() |
提出日時 | 2024-11-22 03:33:42 |
言語 | Elixir (1.18.1) |
結果 |
AC
|
実行時間 | 1,304 ms / 2,000 ms |
コード長 | 855 bytes |
コンパイル時間 | 4,651 ms |
コンパイル使用メモリ | 61,764 KB |
実行使用メモリ | 156,920 KB |
最終ジャッジ日時 | 2024-11-22 03:34:20 |
合計ジャッジ時間 | 32,256 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
defmoduleMain do@spec input() :: binary()def input, do: IO.read(:line) |> String.trimdef ii, do: input() |> String.to_integerdef li, do: input() |> String.split |> Enum.map(&String.to_integer/1)def yn(b), do: IO.puts (if b, do: "Yes", else: "No")def pow(x, n, mod) docond don == 0 -> 1rem(n, 2) == 0 ->y = pow(x, div(n, 2), mod)rem(y * y, mod)true ->rem(x * pow(x, n - 1, mod), mod)endend@mod 998244353def inv(x) dopow(x, @mod-2, @mod)enddef comb(n, k) dofor i <- 1..k//1, reduce: 1 doacc ->x = rem(acc * inv(i), @mod)rem(x * (n-i+1), @mod)endenddef main don = ii()cs = input() |> String.graphemes()ab = cs |> Enum.count(&(&1 == "A" || &1 == "B"))ans = comb(n, ab)IO.puts ansendend