結果

問題 No.371 ぼく悪いプライムじゃないよ
ユーザー maimai
提出日時 2018-05-20 10:58:38
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 416 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 11,448 KB
実行使用メモリ 15,664 KB
最終ジャッジ日時 2023-09-10 23:55:36
合計ジャッジ時間 11,509 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
15,356 KB
testcase_01 AC 89 ms
15,412 KB
testcase_02 AC 90 ms
15,436 KB
testcase_03 WA -
testcase_04 AC 92 ms
15,484 KB
testcase_05 AC 91 ms
15,432 KB
testcase_06 AC 92 ms
15,104 KB
testcase_07 AC 90 ms
15,324 KB
testcase_08 WA -
testcase_09 AC 91 ms
15,416 KB
testcase_10 AC 91 ms
15,256 KB
testcase_11 AC 90 ms
15,152 KB
testcase_12 AC 93 ms
15,408 KB
testcase_13 AC 92 ms
15,216 KB
testcase_14 AC 91 ms
15,412 KB
testcase_15 WA -
testcase_16 AC 92 ms
15,224 KB
testcase_17 AC 90 ms
15,332 KB
testcase_18 AC 88 ms
15,412 KB
testcase_19 AC 89 ms
15,324 KB
testcase_20 WA -
testcase_21 AC 91 ms
15,352 KB
testcase_22 WA -
testcase_23 AC 108 ms
15,392 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 375 ms
15,296 KB
testcase_27 AC 381 ms
15,504 KB
testcase_28 AC 355 ms
15,300 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 382 ms
15,392 KB
testcase_44 AC 267 ms
15,412 KB
testcase_45 AC 89 ms
15,320 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def ascan; gets.split.map(&:to_i);end

require 'prime'

L, H = ascan

sqrtH = Math.sqrt(H).to_i

ans = [0,0]

sqrtH.downto(2) do |x|
    next unless x.prime? ## 篩を使えばこの計算量をループの外に出せる
    y = H / x
    yfact =  y.prime_division.map(&:shift).min ## niceな実装ならO(sqrt(N))
    next if x * y < L
    
    curr = [ [x,yfact].min, x*y ]
    ans = [curr, ans].max
end

p ans[1]
0