結果
問題 | No.2795 Perfect Number |
ユーザー |
|
提出日時 | 2024-07-21 01:21:36 |
言語 | Common Lisp (sbcl 2.5.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 461 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 27,520 KB |
実行使用メモリ | 27,520 KB |
最終ジャッジ日時 | 2024-07-21 01:21:41 |
合計ジャッジ時間 | 3,759 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 2 TLE * 1 -- * 32 |
コンパイルメッセージ
; compiling file "/home/judge/data/code/Main.lisp" (written 21 JUL 2024 01:21:36 AM): ; wrote /home/judge/data/code/Main.fasl ; compilation finished in 0:00:00.007
ソースコード
(defun is-perfect-number (n) (if (< n 2) nil (let ((sum 1) (sqrt-n (isqrt n))) (loop for i from 2 to sqrt-n do (when (zerop (mod n i)) (incf sum i) (let ((other (/ n i))) (unless (= i other) (incf sum other))))) (= sum n)))) (defun main () (let ((n (read))) (if (is-perfect-number n) (format t "Yes~%") (format t "No~%")))) (main)