;;; File: main.scm ;; Author: ymiyamoto ;; ;; Created on Sat Sep 28 20:04:17 2019 ;; (define-syntax read-number (syntax-rules () ((_ nums) (define-values nums (apply values (map string->number (string-split (read-line) #\space))))))) (define-syntax read-numbers (syntax-rules () ((_ as) (define as (map string->number (string-split (read-line) #\space)))) ((_ as n) (define as (map (lambda (_) (map string->number (string-split (read-line) #\space))) (iota n)))))) (define-syntax 1+ (syntax-rules () ((_ x) (+ x 1)))) (define-syntax 1- (syntax-rules () ((_ x) (- x 1)))) (define MOD 1000000007) (define (mod+ a . b) (fold (lambda (x acc) (modulo (+ x acc) MOD)) a b)) (define (mod* a . b) (fold (lambda (x acc) (modulo (* x acc) MOD)) a b)) (define (make-comb num) (define dp (make-vector num -1)) (define (fact n) (vector-ref dp n)) (vector-set! dp 0 1) (let loop ((i 1)) (when (< i num) (vector-set! dp i (mod* i (vector-ref dp (1- i)))) (loop (1+ i)))) (lambda (n k) (define factn (fact n)) (define powk (expt-mod (fact k) (- MOD 2) MOD)) (define pownk (expt-mod (fact (- n k)) (- MOD 2) MOD)) (mod* factn powk pownk))) (define (solve) (define comb (make-comb (* 3 100001))) (read-number (a b c)) (print (apply mod+ (map (lambda (i) (mod* (comb (- (+ a b c) i 2) (- c 1)) (comb (- (+ a b) i 1) (- b 1)) (1- (expt-mod 2 (- (+ a b c) i 1) MOD)))) (iota a 1))))) (solve)