結果

問題 No.534 フィボナッチフィボナッチ数
ユーザー 6soukiti296soukiti29
提出日時 2017-06-24 14:30:37
言語 Nim
(2.0.2)
結果
MLE  
実行時間 -
コード長 1,030 bytes
コンパイル時間 3,017 ms
コンパイル使用メモリ 68,764 KB
実行使用メモリ 814,128 KB
最終ジャッジ日時 2023-09-12 13:11:24
合計ジャッジ時間 6,632 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
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 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/judge/data/code/Main.nim(1, 17) Warning: imported and not used: 'sequtils' [UnusedImport]

ソースコード

diff #

import strutils,sequtils
var m = 2_000_000_016

type
    Matrix[H,W: static[int]] = 
        array[1..H,array[1..W,int64]]
proc `+`[H,W](a,b:Matrix[H,W]):Matrix[H,W] =
    for i in 1..high(a):
        for j in 1..high(a[0]):
            result[i][j] = a[i][j] + b[i][j]
proc `*`[Ha,Wa,Wb](a:Matrix[Ha,Wa],b:Matrix[Wa,Wb]):Matrix[Ha,Wb] =
    var k : int64
    for i in 1.. Ha:
        for j in 1..Wb:
            k = 0
            for ai in 1..Wa:
                k = (k + a[i][ai] * b[ai][j]) mod m
            result[i][j] = k
proc powMatrix[W,H](a : Matrix[W,H], n : int64):Matrix[W,H] =
    if n == 1:
        return a
    if n mod 2 == 0:
        return powMatrix(a * a,n div 2)
    else:
        return powMatrix(a * a,n div 2) * a
proc printMatrix(A: Matrix)=
    for a in A:
        echo a.join(", ")
proc fib(n : int64): int64 =
    var
        A : Matrix[2,2] = [[1.int64,1.int64],[1.int64,0.int64]]
    return (powMatrix(A,n))[2][1]
var N = stdin.readline.parseBiggestInt
N = fib(N)
m = 1_000_000_007
N = fib(N)
echo N
0