結果

問題 No.2380 Sylow P-subgroup
ユーザー オレンジジュース
提出日時 2023-07-21 02:06:12
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 19 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 1,941 ms
コンパイル使用メモリ 192,376 KB
最終ジャッジ日時 2025-02-15 16:03:16
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

using ll = long long;

ll modpow(ll x, ll y, ll m) {
	if (!y) return 1;
	x %= m; if (y % 2) return modpow(x, y - 1, m) * x % m;
	return modpow(x * x % m, y / 2, m);
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(0);

    ll n, p;
    cin >> n >> p;
    ll s = 0;
    while (n > 0) {
        n /= p;
        s += n;
    }
    cout << modpow(p, s, 998244353) << '\n';
    return 0;
}
0