結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー universatouniversato
提出日時 2020-05-29 22:47:32
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 357 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 7,680 KB
実行使用メモリ 17,920 KB
最終ジャッジ日時 2024-04-24 00:19:45
合計ジャッジ時間 5,609 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
17,536 KB
testcase_01 AC 85 ms
12,288 KB
testcase_02 AC 76 ms
12,288 KB
testcase_03 AC 77 ms
12,288 KB
testcase_04 AC 76 ms
12,416 KB
testcase_05 AC 75 ms
12,160 KB
testcase_06 AC 76 ms
12,288 KB
testcase_07 AC 79 ms
12,160 KB
testcase_08 AC 1,232 ms
12,416 KB
testcase_09 AC 76 ms
12,160 KB
testcase_10 TLE -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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