結果

問題 No.2380 Sylow P-subgroup
ユーザー CuriousFairy315CuriousFairy315
提出日時 2023-07-14 21:41:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 2,000 ms
コード長 735 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 71,916 KB
実行使用メモリ 56,504 KB
最終ジャッジ日時 2023-10-14 11:45:20
合計ジャッジ時間 4,739 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,892 KB
testcase_01 AC 117 ms
56,100 KB
testcase_02 AC 113 ms
56,416 KB
testcase_03 AC 116 ms
55,848 KB
testcase_04 AC 115 ms
55,512 KB
testcase_05 AC 108 ms
55,436 KB
testcase_06 AC 112 ms
55,660 KB
testcase_07 AC 111 ms
56,504 KB
testcase_08 AC 116 ms
55,580 KB
testcase_09 AC 111 ms
53,956 KB
testcase_10 AC 110 ms
56,128 KB
testcase_11 AC 115 ms
55,836 KB
testcase_12 AC 110 ms
55,408 KB
testcase_13 AC 108 ms
56,084 KB
testcase_14 AC 110 ms
56,004 KB
testcase_15 AC 113 ms
56,500 KB
testcase_16 AC 108 ms
55,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #


import static java.lang.System.err;

public class Main {
	public static void main(String[] args) {
		java.io.PrintWriter out = new java.io.PrintWriter(System.out);
		new Main(out);
		out.flush();
		err.flush();
	}

	public Main(java.io.PrintWriter out) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			long N = sc.nextLong(), P = sc.nextLong();
			int MOD = 998_244_353;
			long ans = 0;
			for (long i = P;i <= N;i *= P) ans += N / i;
			out.println(pow(P, ans, MOD));
		}
	}

	public static int pow(long a, long b, int mod) {
		if (b < 0) b = b % (mod - 1) + mod - 1;
		long ans = 1;
		for (long mul = a; b > 0; b >>= 1, mul = mul * mul % mod) if ((b & 1) != 0) ans = ans * mul % mod;
		return (int) ans;
	}
}
0