結果

問題 No.2 素因数ゲーム
ユーザー MiyamonY
提出日時 2019-09-10 15:11:47
言語 Scheme
(Gauche-0.9.15)
結果
WA  
実行時間 -
コード長 565 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 29,568 KB
最終ジャッジ日時 2024-07-02 16:16:19
合計ジャッジ時間 5,625 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 24 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

(use math.prime)

(define (read-number)
  (string->number (read-line)))

(let* ((n (read-number)))
  (define primes (naive-factorize n))
  (define assoc '())
  (let loop ((primes primes))
    (unless (null? primes)
      (let1 prime (car primes)
	    (set! assoc (assoc-set! assoc prime (+ 1 (assoc-ref assoc prime 0)))))
      (loop (cdr primes))))

  (if (= (length assoc) 1)
      (print "Alice")
      (let1 num (length (filter (lambda (x) (= (cdr x) 1)) assoc))
	    (if (= (mod (+ num (* 2 (- (length assoc) num))) 2) 0)
		(print "Bob")
		(print "Alice")))))
0