結果
問題 | No.895 MESE |
ユーザー |
|
提出日時 | 2019-09-28 23:08:20 |
言語 | Scheme (Gauche-0.9.15) |
結果 |
AC
|
実行時間 | 1,619 ms / 2,000 ms |
コード長 | 1,672 bytes |
コンパイル時間 | 137 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 37,584 KB |
最終ジャッジ日時 | 2024-10-03 04:18:25 |
合計ジャッジ時間 | 41,899 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 |
ソースコード
;;; 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+ x y) (modulo (+ x y) MOD)) (define (mod* x y) (modulo (* x y) MOD)) (define (make-comb num) (define fact-dp (make-vector num -1)) (define inv-fact-dp (make-vector num -1)) (define (fact n) (vector-ref fact-dp n)) (define (inv-fact n) (vector-ref inv-fact-dp n)) (vector-set! fact-dp 0 1) (vector-set! inv-fact-dp 0 1) (let loop ((i 1)) (when (< i num) (vector-set! fact-dp i (mod* i (fact (1- i)))) (vector-set! inv-fact-dp i (expt-mod (fact i) (- MOD 2) MOD)) (loop (1+ i)))) (lambda (n k) (define factn (fact n)) (define powk (inv-fact k)) (define pownk (inv-fact (- n k))) (mod* (mod* factn powk) pownk))) (define (solve) (define comb (make-comb (* 3 100000))) (read-number (a b c)) (print (fold mod+ 0 (map (lambda (i) (define x (comb (- (+ a b c) i 2) (1- c))) (define y (comb (- (+ a b) i 1) (1- b))) (define z (1- (expt-mod 2 (- (+ a b c) i 1) MOD))) (mod* (mod* x y) z)) (iota a 1))))) (solve)