結果

問題 No.2380 Sylow P-subgroup
ユーザー HIcoder
提出日時 2023-07-24 11:46:31
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 105,756 KB
最終ジャッジ日時 2025-02-15 18:44:05
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
#include<random>
#include<bitset>
//#include<fstream>

using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<ll,ll> P;
typedef pair<int,P> PP;
const ll MOD=998244353;


ll mod_pow(ll x,ll y,ll mod){
    
    ll res=1;

    while(y>0){
        if(y&1){
            res*=x;
            res%=mod;
        }
        x*=x;
        x%=mod;
        y/=2;
    }

    return res;
}


int main(){
    ll n,p;
    cin>>n>>p;

    ll cnt=0;
    while(n>0){
        cnt+=n/p;
        n/=p;
    }

    ll ans=mod_pow(p,cnt,MOD);
    cout<<ans<<endl;
}
0