結果

問題 No.2380 Sylow P-subgroup
ユーザー tnakao0123tnakao0123
提出日時 2023-07-15 16:08:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 595 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 41,652 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-17 02:32:58
合計ジャッジ時間 1,444 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 2380.cc:  No.2380 Sylow P-subgroup - yukicoder
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MOD = 998244353;

/* typedef */

typedef long long ll;

/* global variables */

/* subroutines */

int powmod(int a, ll b) {
  int p = 1;
  while (b > 0) {
    if (b & 1) p = (ll)p * a % MOD;
    a = (ll)a * a % MOD;
    b >>= 1;
  }
  return p;
}

/* main */

int main() {
  ll n;
  int p;
  scanf("%lld%d", &n, &p);

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

  printf("%d\n", powmod(p, e));

  return 0;
}
0