結果
| 問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-03-05 01:16:30 | 
| 言語 | Julia (2.11.2) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,666 ms / 2,000 ms | 
| コード長 | 917 bytes | 
| コンパイル時間 | 115 ms | 
| コンパイル使用メモリ | 6,688 KB | 
| 実行使用メモリ | 315,660 KB | 
| 最終ジャッジ日時 | 2024-10-01 17:48:46 | 
| 合計ジャッジ時間 | 26,621 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 12 | 
ソースコード
module ModIntModule
   export ModInt,+,-,*,/
   struct ModInt{n} <: Integer
      k::UInt64
      ModInt{n}(k::Integer) where{n} = new(mod(k,n))
   end
   import Base: +,-,*,/
   +(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.k + y.k);
   -(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(n + x.k - y.k);
   *(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.k * y.k);
   /(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.k * invmod(y.k, n));
end
using .ModIntModule
Base.show(io::IO, a::ModInt{n}) where {n} = show(io, a.k)
Base.promote_rule(::Type{ModInt{n}}, ::Type{Int}) where {n} = ModInt{n}
Base.convert(::Type{ModInt{n}}, x::Int) where {n} = ModInt{n}(x)
const modint998244353 = ModInt{998244353}
const modint1000000007 = ModInt{1000000007}
using Printf
n, m = parse.(Int32, split(readline()))
a = ModInt{m}.([1 1;1 0])
f = ModInt{m}.([1;0])
f = (a^(n-2))*f
@printf(stdout, "%d\n", f[1].k)
            
            
            
        