結果
問題 | No.526 フィボナッチ数列の第N項をMで割った余りを求める |
ユーザー | otamay6 |
提出日時 | 2024-03-05 01:23:39 |
言語 | Julia (1.10.2) |
結果 |
AC
|
実行時間 | 1,594 ms / 2,000 ms |
コード長 | 969 bytes |
コンパイル時間 | 68 ms |
コンパイル使用メモリ | 6,944 KB |
実行使用メモリ | 305,220 KB |
最終ジャッジ日時 | 2024-04-09 14:37:14 |
合計ジャッジ時間 | 26,012 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1,582 ms
305,040 KB |
testcase_01 | AC | 1,558 ms
302,956 KB |
testcase_02 | AC | 1,571 ms
303,628 KB |
testcase_03 | AC | 1,590 ms
303,328 KB |
testcase_04 | AC | 1,559 ms
304,932 KB |
testcase_05 | AC | 1,560 ms
304,796 KB |
testcase_06 | AC | 1,553 ms
303,300 KB |
testcase_07 | AC | 1,541 ms
305,104 KB |
testcase_08 | AC | 1,566 ms
303,276 KB |
testcase_09 | AC | 1,565 ms
302,996 KB |
testcase_10 | AC | 1,566 ms
305,220 KB |
testcase_11 | AC | 1,565 ms
303,868 KB |
testcase_12 | AC | 1,549 ms
303,608 KB |
testcase_13 | AC | 1,594 ms
303,752 KB |
testcase_14 | AC | 1,530 ms
303,268 KB |
ソースコード
module ModIntModule export ModInt,+,-,*,/ struct ModInt{n} <: Integer value::UInt64 ModInt{n}(value::Integer) where{n} = new(mod(value,n)) end import Base: +,-,*,/ +(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.value + y.value); -(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(n + x.value - y.value); *(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.value * y.value); /(x::ModInt{n}, y::ModInt{n}) where{n} = ModInt{n}(x.value * invmod(y.value, n)); end using .ModIntModule Base.show(io::IO, a::ModInt{n}) where {n} = show(io, a.value) 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].value)