結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー universatouniversato
提出日時 2020-05-29 23:00:29
言語 Crystal
(1.11.2)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 378 bytes
コンパイル時間 16,892 ms
コンパイル使用メモリ 256,584 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2023-09-13 10:38:31
合計ジャッジ時間 18,915 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,920 KB
testcase_01 AC 3 ms
5,992 KB
testcase_02 AC 4 ms
6,008 KB
testcase_03 AC 3 ms
6,068 KB
testcase_04 AC 4 ms
5,896 KB
testcase_05 AC 4 ms
5,992 KB
testcase_06 AC 4 ms
5,996 KB
testcase_07 AC 3 ms
5,980 KB
testcase_08 AC 53 ms
6,624 KB
testcase_09 AC 3 ms
6,116 KB
testcase_10 AC 136 ms
6,784 KB
testcase_11 AC 32 ms
6,364 KB
testcase_12 AC 25 ms
6,380 KB
testcase_13 AC 33 ms
6,452 KB
testcase_14 AC 35 ms
6,384 KB
testcase_15 AC 92 ms
6,736 KB
testcase_16 AC 16 ms
6,248 KB
testcase_17 AC 18 ms
6,260 KB
testcase_18 AC 84 ms
6,564 KB
testcase_19 AC 31 ms
6,412 KB
testcase_20 AC 4 ms
6,020 KB
testcase_21 AC 65 ms
6,616 KB
testcase_22 AC 4 ms
5,964 KB
testcase_23 AC 4 ms
6,000 KB
testcase_24 AC 4 ms
6,012 KB
testcase_25 AC 141 ms
6,720 KB
testcase_26 AC 140 ms
6,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353

n, q = gets.to_s.split.map{|t| t.to_i64 }
a    = gets.to_s.split.map{|t| t.to_i64 }
b    = gets.to_s.split.map{|t| t.to_i64 }

dp = Array.new(2*10**5+10){ 0_i64 }
dp[0] = 1_i64

a.each_with_index do |t, i|
  
  i.downto(0) do |j|
    dp[j+1] = ( dp[j+1] +dp[j] ) % mod
    dp[j] = ( dp[j] * (t - 1) ) % mod
  end
end

b.map!{|t| dp[t] % mod }

puts b.join("\n")
0