結果

問題 No.2380 Sylow P-subgroup
ユーザー steinnsteinn
提出日時 2023-07-17 16:42:14
言語 Julia
(1.10.2)
結果
AC  
実行時間 334 ms / 2,000 ms
コード長 1,215 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 6,940 KB
実行使用メモリ 251,720 KB
最終ジャッジ日時 2024-04-09 14:29:10
合計ジャッジ時間 6,723 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 331 ms
250,344 KB
testcase_01 AC 332 ms
251,720 KB
testcase_02 AC 329 ms
249,448 KB
testcase_03 AC 328 ms
249,880 KB
testcase_04 AC 332 ms
250,836 KB
testcase_05 AC 327 ms
249,984 KB
testcase_06 AC 334 ms
250,604 KB
testcase_07 AC 330 ms
249,848 KB
testcase_08 AC 327 ms
249,288 KB
testcase_09 AC 326 ms
250,404 KB
testcase_10 AC 331 ms
250,100 KB
testcase_11 AC 333 ms
249,984 KB
testcase_12 AC 330 ms
249,696 KB
testcase_13 AC 328 ms
249,484 KB
testcase_14 AC 328 ms
249,872 KB
testcase_15 AC 327 ms
249,512 KB
testcase_16 AC 329 ms
249,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

parseInt() = parse.(Int64, readline()::String |> split)::Vector{Int64}
parseInt2() = parse.(Int64, readline()::String |> collect)::Vector{Int64}
parseInt3() = parse(Int64, readline()::String)::Int64

module Modulo
mod = 998244353

export Mint, pow
mutable struct Mint
    m::Int64
    Mint(x) = x ≥ 0 ? new(x % mod) : new((mod - (-x) % mod) % mod)
end

function Base.:+(x::Mint, y::Mint)
    return Mint(+(x.m, y.m))
end

function Base.:-(x::Mint, y::Mint)
    return Mint(-(x.m, y.m))
end

function Base.:*(x::Mint, y::Mint)
    return Mint(*(x.m, y.m))
end

function inverse(x::Mint)
    a = x.m
    b = mod
    u = 1
    v = 0
    while b > 0
        t = a ÷ b
        a -= t * b
        a, b = b, a
        u -= t * v
        u, v = v, u
    end
    return Mint(u)
end

function Base.:/(x::Mint, y::Mint)
    return x * inverse(y)
end

function pow(x::Mint, n::Int64)
    ret = Mint(1)
    while n > 0
        if n & 1 != 0
            ret *= x
        end
        x *= x
        n >>= 1
    end
    return ret
end

end

using .Modulo

function main()
    n, p = parseInt()
    k = p
    num = 0
    while n ÷ k > 0
        num += n ÷ k
        k *= p
    end
    pow(Mint(p), num).m |> println
end

main()
0