結果

問題 No.7 プライムナンバーゲーム
ユーザー zazaboonzazaboon
提出日時 2017-05-08 15:02:03
言語 Ruby
(3.2.2)
結果
WA  
実行時間 -
コード長 455 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 11,248 KB
実行使用メモリ 15,604 KB
最終ジャッジ日時 2023-10-12 18:57:46
合計ジャッジ時間 4,872 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
15,364 KB
testcase_01 WA -
testcase_02 AC 304 ms
15,524 KB
testcase_03 AC 109 ms
15,540 KB
testcase_04 AC 100 ms
15,364 KB
testcase_05 WA -
testcase_06 AC 158 ms
15,420 KB
testcase_07 AC 138 ms
15,388 KB
testcase_08 AC 116 ms
15,440 KB
testcase_09 WA -
testcase_10 AC 98 ms
15,604 KB
testcase_11 AC 140 ms
15,576 KB
testcase_12 AC 246 ms
15,468 KB
testcase_13 AC 254 ms
15,584 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 277 ms
15,552 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

require "prime"
ss = Prime.each(10000).to_a
ans = Array.new(10001)
n=gets.to_i
(n+1).times do |d|
    if(d < 2)
        ans[d] = true
    elsif(d<4)
        ans[d] = false
    else
        f=0
        ss.each do |pr|
            break if(pr > d)
            if(ans[d-pr] == false)
                ans[d] = true
                f=1
                break 
            end
        end
        ans[d]=false unless(f==1)
    end
end
puts ans[n]? "Win" : "Loss"
0