結果
問題 |
No.7 プライムナンバーゲーム
|
ユーザー |
|
提出日時 | 2015-10-18 13:35:10 |
言語 | F# (F# 4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 831 bytes |
コンパイル時間 | 11,263 ms |
コンパイル使用メモリ | 185,040 KB |
実行使用メモリ | 42,000 KB |
最終ジャッジ日時 | 2024-07-21 16:51:27 |
合計ジャッジ時間 | 13,683 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | RE * 17 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.fsproj を復元しました (611 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.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 プライムナンバーゲーム`` ()