結果
問題 | No.891 隣接3項間の漸化式 |
ユーザー | MiyamonY |
提出日時 | 2019-09-29 00:25:48 |
言語 | Scheme (Gauche-0.9.14) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 1,386 bytes |
コンパイル時間 | 22 ms |
コンパイル使用メモリ | 6,692 KB |
実行使用メモリ | 17,792 KB |
最終ジャッジ日時 | 2024-10-03 04:20:31 |
合計ジャッジ時間 | 2,802 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
17,664 KB |
testcase_01 | AC | 37 ms
17,536 KB |
testcase_02 | AC | 36 ms
17,536 KB |
testcase_03 | AC | 36 ms
17,536 KB |
testcase_04 | AC | 35 ms
17,536 KB |
testcase_05 | AC | 36 ms
17,664 KB |
testcase_06 | AC | 35 ms
17,536 KB |
testcase_07 | AC | 35 ms
17,664 KB |
testcase_08 | AC | 37 ms
17,536 KB |
testcase_09 | AC | 37 ms
17,536 KB |
testcase_10 | AC | 37 ms
17,664 KB |
testcase_11 | AC | 36 ms
17,536 KB |
testcase_12 | AC | 39 ms
17,536 KB |
testcase_13 | AC | 24 ms
16,640 KB |
testcase_14 | AC | 24 ms
16,640 KB |
testcase_15 | AC | 36 ms
17,664 KB |
testcase_16 | AC | 35 ms
17,536 KB |
testcase_17 | AC | 23 ms
16,640 KB |
testcase_18 | AC | 23 ms
16,640 KB |
testcase_19 | AC | 35 ms
17,536 KB |
testcase_20 | AC | 22 ms
16,640 KB |
testcase_21 | AC | 23 ms
16,768 KB |
testcase_22 | AC | 36 ms
17,664 KB |
testcase_23 | AC | 23 ms
16,640 KB |
testcase_24 | AC | 23 ms
16,640 KB |
testcase_25 | AC | 35 ms
17,536 KB |
testcase_26 | AC | 36 ms
17,536 KB |
testcase_27 | AC | 44 ms
17,536 KB |
testcase_28 | AC | 36 ms
17,536 KB |
testcase_29 | AC | 38 ms
17,664 KB |
testcase_30 | AC | 37 ms
17,536 KB |
testcase_31 | AC | 38 ms
17,536 KB |
testcase_32 | AC | 35 ms
17,536 KB |
testcase_33 | AC | 38 ms
17,792 KB |
testcase_34 | AC | 35 ms
17,536 KB |
testcase_35 | AC | 36 ms
17,536 KB |
testcase_36 | AC | 35 ms
17,536 KB |
testcase_37 | AC | 36 ms
17,536 KB |
testcase_38 | AC | 35 ms
17,664 KB |
testcase_39 | AC | 36 ms
17,664 KB |
testcase_40 | AC | 36 ms
17,408 KB |
testcase_41 | AC | 37 ms
17,664 KB |
ソースコード
;;; File: main.scm ;; Author: ymiyamoto ;; ;; Created on Sat Sep 28 23:46:29 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 prlist (syntax-rules () ((_ lis) (print (string-join (map number->string lis) " "))))) (define-syntax 1+ (syntax-rules () ((_ x) (+ x 1)))) (define-syntax 1- (syntax-rules () ((_ x) (- x 1)))) (define MOD 1000000007) (define (mod+ a b) (modulo (+ a b) MOD)) (define (mod* a b) (modulo (* a b) MOD)) (use util.match) (define (matrix* x y) (match x (((a0 b0) (c0 d0)) (match y (((a1 b1) (c1 d1)) (list (list (mod+ (mod* a0 a1) (mod* b0 c1)) (mod+ (mod* a0 b1) (mod* b0 d1))) (list (mod+ (mod* c0 a1) (mod* d0 c1)) (mod+ (mod* c0 b1) (mod* d0 d1))))))))) (define (solve) (read-number (a b n)) (define (prod a n) (cond ((= n 0) '((1 0) (0 1))) ((even? n) (prod (matrix* a a) (div n 2))) (else (matrix* a (prod a (1- n)))))) (print (car (cadr (prod (list (list a b) '(1 0)) n))))) (solve)