結果

問題 No.638 Sum of "not power of 2"
コンテスト
ユーザー CreativeGP1
提出日時 2018-02-21 20:56:29
言語 Scheme
(Gauche-0.9.15)
コンパイル:
true
実行:
gosh _filename_
結果
MLE  
実行時間 -
コード長 662 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 121 ms
コンパイル使用メモリ 6,528 KB
実行使用メモリ 751,232 KB
最終ジャッジ日時 2026-04-07 21:10:08
合計ジャッジ時間 2,904 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 2
other AC * 8 MLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

(define (slist->string slst)
  (string-join (map symbol->string slst) " "))
                           
(define N (read))

(define s2
  (lambda (n) (if (<= n 1) (if (= n 1) #t #f) (s2 (/ n 2)))))


(define (list-of-sum n a)
  (if (= a 0)
      '()
    (cons (list a (- n a)) (list-of-sum n (- a 1)))))
  
  
(define (last_element l)
  (cond ((null? (cdr l)) (car l))
        (else (last_element (cdr l)))))

(let ((ans (filter (lambda (n) (and (not (s2 (list-ref n 0))) (not (s2 (list-ref n 1))))) (list-of-sum N (- N 1)))))
     (display (if (= 0 (length ans)) "-1\n" (format "~a ~a\n" (list-ref (last_element ans) 0) (list-ref (last_element ans) 1)) 
     )))
0