結果

問題 No.2380 Sylow P-subgroup
ユーザー 👑 kakel-sankakel-san
提出日時 2023-07-14 22:51:29
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 942 bytes
コンパイル時間 1,315 ms
コンパイル使用メモリ 63,840 KB
実行使用メモリ 23,852 KB
最終ジャッジ日時 2023-10-14 13:11:02
合計ジャッジ時間 3,151 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 62 ms
23,784 KB
testcase_01 AC 62 ms
21,932 KB
testcase_02 AC 62 ms
21,988 KB
testcase_03 AC 61 ms
21,816 KB
testcase_04 AC 62 ms
21,804 KB
testcase_05 AC 62 ms
21,856 KB
testcase_06 AC 62 ms
19,848 KB
testcase_07 AC 61 ms
23,712 KB
testcase_08 AC 61 ms
21,708 KB
testcase_09 AC 62 ms
23,756 KB
testcase_10 AC 61 ms
23,852 KB
testcase_11 AC 61 ms
23,852 KB
testcase_12 AC 61 ms
21,816 KB
testcase_13 WA -
testcase_14 AC 62 ms
23,744 KB
testcase_15 AC 60 ms
21,688 KB
testcase_16 AC 62 ms
23,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static long NN => long.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, p) = (c[0], c[1]);
        var mul = 0L;
        var tmp = p;
        while (true)
        {
            if (tmp > n) break;
            mul += n / tmp;
            tmp *= p;
        }
        var mod = 998_244_353;
        WriteLine(Exp((int)p, (int)(mul % mod), mod));
    }
    static long Exp(int n, int k, int mod)
    {
        if (k == 0) return 1;
        if (k == 1) return n % mod;
        var half = Exp(n, k / 2, mod);
        var result = (half * half) % mod;
        return ((k % 2) == 0) ? result : ((result * n) % mod);
    }
}
0