結果

問題 No.895 MESE
ユーザー MiyamonYMiyamonY
提出日時 2019-09-28 21:09:49
言語 Scheme
(Gauche-0.9.14)
結果
TLE  
実行時間 -
コード長 1,272 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 66,432 KB
最終ジャッジ日時 2024-04-14 07:01:33
合計ジャッジ時間 10,935 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
24,096 KB
testcase_01 AC 34 ms
17,024 KB
testcase_02 AC 63 ms
17,792 KB
testcase_03 AC 36 ms
17,024 KB
testcase_04 AC 36 ms
17,024 KB
testcase_05 AC 36 ms
17,152 KB
testcase_06 AC 35 ms
17,024 KB
testcase_07 AC 35 ms
17,024 KB
testcase_08 AC 1,132 ms
20,992 KB
testcase_09 AC 619 ms
20,736 KB
testcase_10 AC 1,389 ms
20,736 KB
testcase_11 AC 1,962 ms
20,736 KB
testcase_12 AC 679 ms
20,736 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

;;; 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 (comb n k)
  (define (fact n)
    (if (<= n 0)
	1
	(mod* n (fact (1- n)))))
  (let ((factn (fact n))
	(powk (expt-mod (fact k) (- MOD 2) MOD))
	(pownk (expt-mod (fact (- n k)) (- MOD 2) MOD)))
    (mod* factn powk pownk)))

(define (solve)
  (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)
0