(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)