結果
| 問題 | No.7 プライムナンバーゲーム |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-10-18 13:35:10 |
| 言語 | F# (F# 10.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 831 bytes |
| 記録 | |
| コンパイル時間 | 8,488 ms |
| コンパイル使用メモリ | 212,468 KB |
| 実行使用メモリ | 43,392 KB |
| 最終ジャッジ日時 | 2026-04-03 05:23:09 |
| 合計ジャッジ時間 | 16,320 ms |
|
ジャッジサーバーID (参考情報) |
judge5_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | RE * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (206 ミリ秒)。 main -> /home/judge/data/code/bin/Release/net10.0/main.dll main -> /home/judge/data/code/bin/Release/net10.0/publish/
ソースコード
#nowarn "40"
let ``No.7 プライムナンバーゲーム`` () =
let rec primes =
Seq.cache <| seq { yield 2; yield! Seq.unfold nextPrime 3 }
and nextPrime n =
if isPrime n then Some(n, n + 2) else nextPrime(n + 2)
and isPrime n =
if n >= 2 then
primes
|> Seq.tryFind (fun x -> n % x = 0 || x * x > n)
|> fun x -> x.Value * x.Value > n
else false
let N = int <| stdin.ReadLine()
// 素数による分割数
let p n = primes |> Seq.item n
let rec pd m =
let dp = Array.init (m+1) (fun _ -> 0)
dp.[0] <- 1
for a in 0..m do
for b in (p a)..m do
dp.[b] <- dp.[b] + dp.[b - p a]
dp.[m]
printfn "%s" ["Win";"Lose";].[(pd N) &&& 1]
``No.7 プライムナンバーゲーム`` ()