結果
| 問題 |
No.7 プライムナンバーゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-09-04 11:28:04 |
| 言語 | Scheme (Gauche-0.9.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 626 bytes |
| コンパイル時間 | 239 ms |
| コンパイル使用メモリ | 6,944 KB |
| 実行使用メモリ | 31,752 KB |
| 最終ジャッジ日時 | 2024-12-26 05:01:14 |
| 合計ジャッジ時間 | 5,108 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 17 |
ソースコード
(use math.prime)
(let ((n (read)))
(define primes (filter small-prime? (iota (+ n 1))))
(define result
(let loop ((i 0)
(vec (make-vector (+ n 1) 0)))
(cond ((= i (+ n 1))
(print (vector->list vec))
(vector-ref vec n))
(else
(let1 winner
(if (<= i 3)
2
(let check-win ((ps primes))
(if (null? ps)
2
(let1 pred (- i (car ps))
(if (and (>= pred 2) (= (vector-ref vec pred) 2))
1
(check-win (cdr ps)))))))
(vector-set! vec i winner)
(loop (+ i 1) vec))))))
(print (if (= result 1) "Win" "Lose")))