結果

問題 No.375 立方体のN等分 (1)
ユーザー pekempeypekempey
提出日時 2016-07-28 17:46:21
言語 Scheme
(Gauche-0.9.14)
結果
AC  
実行時間 4,474 ms / 5,000 ms
コード長 1,058 bytes
コンパイル時間 54 ms
コンパイル使用メモリ 5,376 KB
実行使用メモリ 59,648 KB
最終ジャッジ日時 2024-04-24 10:34:55
合計ジャッジ時間 11,894 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
15,872 KB
testcase_01 AC 25 ms
15,872 KB
testcase_02 AC 211 ms
17,280 KB
testcase_03 AC 25 ms
16,128 KB
testcase_04 AC 26 ms
16,000 KB
testcase_05 AC 25 ms
16,000 KB
testcase_06 AC 27 ms
16,000 KB
testcase_07 AC 47 ms
16,000 KB
testcase_08 AC 255 ms
21,120 KB
testcase_09 AC 39 ms
15,872 KB
testcase_10 AC 69 ms
15,872 KB
testcase_11 AC 65 ms
16,000 KB
testcase_12 AC 75 ms
16,000 KB
testcase_13 AC 74 ms
16,128 KB
testcase_14 AC 892 ms
29,696 KB
testcase_15 AC 101 ms
16,000 KB
testcase_16 AC 74 ms
16,256 KB
testcase_17 AC 2,176 ms
37,248 KB
testcase_18 AC 917 ms
29,568 KB
testcase_19 AC 97 ms
16,256 KB
testcase_20 AC 53 ms
15,872 KB
testcase_21 AC 55 ms
16,128 KB
testcase_22 AC 4,474 ms
59,648 KB
testcase_23 AC 78 ms
15,872 KB
testcase_24 AC 54 ms
16,000 KB
testcase_25 AC 187 ms
17,408 KB
testcase_26 AC 71 ms
15,872 KB
testcase_27 AC 101 ms
16,000 KB
testcase_28 AC 53 ms
15,872 KB
testcase_29 AC 54 ms
15,872 KB
testcase_30 AC 73 ms
15,872 KB
testcase_31 AC 86 ms
16,000 KB
testcase_32 AC 54 ms
16,000 KB
testcase_33 AC 77 ms
15,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

(define divisors2
  (lambda (n i res)
    (if (> (* i i) n)
      res
      (if (= (remainder n i) 0)
        (if (= (* i i) n)
          (divisors2 n (+ i 1) (cons (cons i i) res))
          (divisors2 n (+ i 1) (cons (cons i (quotient n i)) res)))
        (divisors2 n (+ i 1) res)))))

(define divisors3
  (lambda (n i res)
    (if (> (* i i i) n)
      res
      (if (= (remainder n i) 0)
        (divisors3 n (+ i 1) (append res (map (lambda (x) (cons i x)) (divisors2 (quotient n i) 1 '()))))
        (divisors3 n (+ i 1) res)))))

(define foldr
  (lambda (f e L)
    (if (null? L) e
      (f (car L) (foldr f e (cdr L))))))

(define min-element
  (lambda (L)
    (foldr min (car L) L)))

(define solve-min
  (lambda (N)
    (min-element (map (lambda (pqr)
                        (let ((p (car pqr)) (q (cadr pqr)) (r (cddr pqr)))
                          (+ (- p 1) (- q 1) (- r 1)))) (divisors3 N 1 '())))))

(define solve-max
  (lambda (N)
    (- N 1)))

(define N (read))

(display (solve-min N))
(display " ")
(display (solve-max N))
(newline) 
0