結果

問題 No.1066 #いろいろな色 / Red and Blue and more various colors (Easy)
ユーザー universatouniversato
提出日時 2020-05-30 07:11:36
言語 Ruby
(3.3.0)
結果
TLE  
実行時間 -
コード長 361 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 17,536 KB
最終ジャッジ日時 2024-04-24 16:23:27
合計ジャッジ時間 5,883 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
17,536 KB
testcase_01 AC 77 ms
12,160 KB
testcase_02 AC 82 ms
12,160 KB
testcase_03 AC 81 ms
12,160 KB
testcase_04 AC 81 ms
12,160 KB
testcase_05 AC 79 ms
12,160 KB
testcase_06 AC 79 ms
12,288 KB
testcase_07 AC 77 ms
12,160 KB
testcase_08 AC 1,155 ms
12,544 KB
testcase_09 AC 83 ms
12,032 KB
testcase_10 TLE -
testcase_11 AC 704 ms
12,544 KB
testcase_12 AC 540 ms
12,544 KB
testcase_13 AC 714 ms
12,544 KB
testcase_14 AC 752 ms
12,416 KB
testcase_15 AC 1,999 ms
12,800 KB
testcase_16 AC 343 ms
12,288 KB
testcase_17 AC 397 ms
12,416 KB
testcase_18 AC 1,821 ms
12,672 KB
testcase_19 AC 668 ms
12,544 KB
testcase_20 AC 81 ms
12,416 KB
testcase_21 AC 1,412 ms
12,800 KB
testcase_22 AC 85 ms
12,160 KB
testcase_23 AC 86 ms
12,416 KB
testcase_24 AC 80 ms
12,160 KB
testcase_25 TLE -
testcase_26 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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]
    dp[j] = ( dp[j] * (t - 1) ) % mod
  end
end

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

puts b.join("\n")
0