結果

問題 No.1050 Zero (Maximum)
ユーザー ikdikd
提出日時 2020-05-09 11:35:51
言語 F#
(F# 4.0)
結果
AC  
実行時間 263 ms / 2,000 ms
コード長 930 bytes
コンパイル時間 5,666 ms
コンパイル使用メモリ 169,148 KB
実行使用メモリ 24,924 KB
最終ジャッジ日時 2023-09-18 18:49:26
合計ジャッジ時間 9,163 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
22,824 KB
testcase_01 AC 83 ms
22,820 KB
testcase_02 AC 115 ms
20,796 KB
testcase_03 AC 105 ms
22,808 KB
testcase_04 AC 186 ms
24,924 KB
testcase_05 AC 196 ms
22,868 KB
testcase_06 AC 130 ms
24,860 KB
testcase_07 AC 141 ms
22,732 KB
testcase_08 AC 87 ms
22,828 KB
testcase_09 AC 113 ms
22,864 KB
testcase_10 AC 230 ms
22,856 KB
testcase_11 AC 182 ms
24,748 KB
testcase_12 AC 85 ms
22,856 KB
testcase_13 AC 82 ms
20,816 KB
testcase_14 AC 84 ms
22,952 KB
testcase_15 AC 82 ms
24,816 KB
testcase_16 AC 243 ms
22,788 KB
testcase_17 AC 263 ms
24,872 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) F# Compiler version 11.0.0.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.

/home/judge/data/code/Main.fs(28,9): warning FS0025: Incomplete pattern matches on this expression. For example, the value '[|_; _; _|]' may indicate a case not covered by the pattern(s).

ソースコード

diff #

// Learn more about F# at http://fsharp.org

open System

let mo = 1000000007L
let inline (+%=) (x: byref<int64>) y = x <- (x + y) % mo
let inline ( *% ) x y = x * y % mo

type mat = int64 [] []

let inline ( *@ ) (a: mat) (b: mat) =
    let n = a.Length
    let mutable c = Array.init n (fun _ -> Array.create n 0L)
    for i = 0 to n - 1 do
        for j = 0 to n - 1 do
            for k = 0 to n - 1 do
                &c.[i].[j] +%= a.[i].[k] *% b.[k].[j]
    c

let rec matpow a n =
    if n = 1 then a
    elif n % 2 = 0 then matpow (a *@ a) (n / 2)
    else a *@ matpow a (n - 1)


[<EntryPoint>]
let main argv =
    let [| m; k |] = stdin.ReadLine().Split() |> Array.map int
    let mutable a = Array.init m (fun _ -> Array.create m 1L)
    for n = 0 to m - 1 do
        for i = 0 to m - 1 do
            &a.[n].[n * i % m] +%= 1L

    let b = (matpow a k)
    printfn "%d" b.[0].[0]
    0 // return an integer exit code
0