結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,876 KB
testcase_01 AC 60 ms
21,916 KB
testcase_02 AC 61 ms
21,864 KB
testcase_03 AC 63 ms
21,824 KB
testcase_04 AC 62 ms
21,896 KB
testcase_05 AC 61 ms
21,852 KB
testcase_06 AC 61 ms
23,908 KB
testcase_07 AC 61 ms
21,816 KB
testcase_08 AC 61 ms
21,856 KB
testcase_09 AC 60 ms
21,840 KB
testcase_10 AC 61 ms
21,808 KB
testcase_11 AC 62 ms
21,804 KB
testcase_12 AC 61 ms
19,908 KB
testcase_13 WA -
testcase_14 AC 61 ms
21,852 KB
testcase_15 AC 60 ms
21,804 KB
testcase_16 AC 61 ms
23,920 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;
        var mod = 998_244_353;
        checked {
        while (true)
        {
            if (tmp > n) break;
            // mul = (mul + n / tmp) % mod;
            mul += n / tmp;
            tmp *= p;
        }
        }
        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