結果
問題 | No.2380 Sylow P-subgroup |
ユーザー |
![]() |
提出日時 | 2023-07-15 02:28:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 703 bytes |
コンパイル時間 | 1,393 ms |
コンパイル使用メモリ | 166,728 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-16 11:07:23 |
合計ジャッジ時間 | 2,026 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define ll long long#define rep(i, a, n) for (int i = (int)(a); i < (int)(n); i++)#define rrep(i, n, a) for (int i = (int)(n); i >= (int)(a); i--)const int P = 998244353;void solve(){ll n,p; cin >> n >> p;ll e = 0;while(n > 0){e += n/p;n /= p;}string s = "";while(e > 0){if(e % 2 == 0){s+='0';} else{s+='1';}e /= 2;}ll ans = 1;for(int i = s.size()-1;i >= 0;i--){ans = (ans*ans)%P;if(s[i] == '1'){ans = (ans*p)%P;}}cout << ans;}int main(){solve();return 0;}