結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー universato
提出日時 2020-05-29 22:47:32
言語 Ruby
(3.4.1)
結果
TLE  
実行時間 -
コード長 357 bytes
コンパイル時間 231 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 19,496 KB
最終ジャッジ日時 2024-11-06 06:50:56
合計ジャッジ時間 6,060 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 7 TLE * 1 -- * 16
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:13: warning: `+' after local variable or literal is interpreted as binary operator
Main.rb:13: warning: even though it seems like unary operator
Main.rb:3: warning: assigned but unused variable - q
Syntax OK

ソースコード

diff #

mod = 998244353

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

dp = Array.new(n+2){ 0 }
dp[0] = 1

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