結果

問題 No.854 公平なりんご分配
ユーザー letrangerjpletrangerjp
提出日時 2019-07-26 22:11:18
言語 Ruby
(3.3.0)
結果
MLE  
実行時間 -
コード長 540 bytes
コンパイル時間 295 ms
コンパイル使用メモリ 11,208 KB
実行使用メモリ 818,480 KB
最終ジャッジ日時 2023-09-15 01:51:23
合計ジャッジ時間 39,637 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
15,304 KB
testcase_01 AC 87 ms
15,188 KB
testcase_02 AC 86 ms
15,208 KB
testcase_03 AC 86 ms
15,104 KB
testcase_04 AC 86 ms
15,208 KB
testcase_05 AC 86 ms
15,220 KB
testcase_06 AC 85 ms
15,324 KB
testcase_07 AC 86 ms
15,308 KB
testcase_08 AC 86 ms
15,152 KB
testcase_09 AC 86 ms
15,412 KB
testcase_10 AC 86 ms
15,352 KB
testcase_11 AC 86 ms
15,308 KB
testcase_12 AC 86 ms
15,152 KB
testcase_13 AC 85 ms
15,156 KB
testcase_14 AC 85 ms
15,108 KB
testcase_15 AC 86 ms
15,312 KB
testcase_16 AC 86 ms
15,104 KB
testcase_17 AC 86 ms
15,360 KB
testcase_18 AC 86 ms
15,188 KB
testcase_19 AC 85 ms
15,192 KB
testcase_20 AC 87 ms
15,352 KB
testcase_21 AC 90 ms
15,160 KB
testcase_22 AC 96 ms
16,072 KB
testcase_23 AC 95 ms
17,548 KB
testcase_24 AC 108 ms
20,496 KB
testcase_25 AC 92 ms
16,464 KB
testcase_26 AC 109 ms
20,972 KB
testcase_27 AC 101 ms
20,644 KB
testcase_28 AC 96 ms
15,876 KB
testcase_29 AC 91 ms
15,876 KB
testcase_30 AC 93 ms
16,636 KB
testcase_31 AC 107 ms
19,616 KB
testcase_32 AC 539 ms
299,840 KB
testcase_33 AC 407 ms
158,828 KB
testcase_34 MLE -
testcase_35 MLE -
testcase_36 AC 257 ms
26,828 KB
testcase_37 AC 476 ms
277,624 KB
testcase_38 AC 409 ms
224,548 KB
testcase_39 MLE -
testcase_40 AC 434 ms
136,716 KB
testcase_41 AC 578 ms
259,084 KB
testcase_42 MLE -
testcase_43 AC 691 ms
272,804 KB
testcase_44 MLE -
testcase_45 AC 478 ms
73,568 KB
testcase_46 MLE -
testcase_47 AC 449 ms
208,052 KB
testcase_48 MLE -
testcase_49 MLE -
testcase_50 AC 476 ms
274,128 KB
testcase_51 MLE -
testcase_52 AC 539 ms
173,164 KB
testcase_53 AC 371 ms
164,620 KB
testcase_54 AC 554 ms
203,232 KB
testcase_55 AC 326 ms
167,376 KB
testcase_56 AC 324 ms
173,080 KB
testcase_57 AC 378 ms
140,044 KB
testcase_58 AC 436 ms
60,504 KB
testcase_59 AC 266 ms
121,116 KB
testcase_60 AC 402 ms
143,140 KB
testcase_61 AC 199 ms
28,628 KB
testcase_62 AC 446 ms
122,012 KB
testcase_63 AC 356 ms
125,708 KB
testcase_64 AC 181 ms
43,680 KB
testcase_65 MLE -
testcase_66 AC 297 ms
89,076 KB
testcase_67 AC 552 ms
227,740 KB
testcase_68 AC 390 ms
96,336 KB
testcase_69 MLE -
testcase_70 AC 289 ms
134,500 KB
testcase_71 AC 301 ms
151,172 KB
testcase_72 AC 306 ms
29,212 KB
testcase_73 AC 460 ms
284,904 KB
testcase_74 MLE -
testcase_75 AC 380 ms
153,004 KB
testcase_76 AC 524 ms
271,200 KB
testcase_77 MLE -
testcase_78 AC 488 ms
111,164 KB
testcase_79 AC 595 ms
237,360 KB
testcase_80 AC 600 ms
248,628 KB
testcase_81 AC 485 ms
257,360 KB
testcase_82 MLE -
testcase_83 -- -
testcase_84 -- -
testcase_85 -- -
testcase_86 -- -
testcase_87 -- -
testcase_88 -- -
testcase_89 -- -
testcase_90 -- -
testcase_91 -- -
testcase_92 -- -
testcase_93 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "prime"

$memo = { 0 => [[0, 1]] }
def f(n)
  $memo[n] ||= n.prime_division
end

P = 10**9+7

N = gets.to_i
A = gets.split.map &:to_i
Q = gets.to_i
PLR = $<.map{|s|
  s.split.map &:to_i
}

$cusum = [primes = Hash.new(0)] + A.map{|a|
  primes = primes.dup
  f(a).each{|k, v|
    primes[k] += v
  }
  primes
}

PLR.each{|p, l, r|
  # p f(p)
  # puts [$cusum[r], $cusum[l-1]]
  if $cusum[r][0] - $cusum[l-1][0] > 0
    puts "Yes"
  elsif f(p).all?{|k, v| $cusum[r][k] - $cusum[l-1][k] >= v }
    puts "Yes"
  else
    puts "NO"
  end
}
0