結果
| 問題 |
No.2380 Sylow P-subgroup
|
| ユーザー |
CuriousFairy315
|
| 提出日時 | 2023-07-14 21:41:20 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 131 ms / 2,000 ms |
| コード長 | 735 bytes |
| コンパイル時間 | 2,160 ms |
| コンパイル使用メモリ | 74,712 KB |
| 実行使用メモリ | 54,380 KB |
| 最終ジャッジ日時 | 2024-09-16 06:35:24 |
| 合計ジャッジ時間 | 4,948 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge6 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 |
ソースコード
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;
}
}
CuriousFairy315