結果

問題 No.638 Sum of "not power of 2"
ユーザー CreativeGP1CreativeGP1
提出日時 2018-02-21 20:56:29
言語 Scheme
(Gauche-0.9.13)
結果
TLE  
実行時間 -
コード長 662 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 5,152 KB
実行使用メモリ 446,020 KB
最終ジャッジ日時 2023-10-19 14:30:32
合計ジャッジ時間 3,308 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
20,440 KB
testcase_01 AC 27 ms
16,092 KB
testcase_02 AC 28 ms
16,092 KB
testcase_03 AC 29 ms
16,092 KB
testcase_04 AC 28 ms
16,100 KB
testcase_05 AC 28 ms
16,092 KB
testcase_06 AC 27 ms
16,100 KB
testcase_07 AC 32 ms
16,100 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

(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