結果

問題 No.2576 LCM Pattern
ユーザー 👑 chro_96chro_96
提出日時 2023-12-18 23:32:25
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 952 ms
コンパイル使用メモリ 30,676 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-12-18 23:32:28
合計ジャッジ時間 2,821 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 1 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 49 ms
6,676 KB
testcase_07 AC 41 ms
6,676 KB
testcase_08 AC 39 ms
6,676 KB
testcase_09 AC 36 ms
6,676 KB
testcase_10 AC 50 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 48 ms
6,676 KB
testcase_13 AC 25 ms
6,676 KB
testcase_14 AC 40 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 1 ms
6,676 KB
testcase_17 AC 11 ms
6,676 KB
testcase_18 AC 11 ms
6,676 KB
testcase_19 AC 36 ms
6,676 KB
testcase_20 AC 31 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 1 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long power_mod (long long a, long long b, long long mod_num) {
  long long ans = 1LL;
  
  if (b > 0LL) {
    ans = power_mod(a, b/2LL, mod_num);
    ans = (ans * ans) % mod_num;
    if (b%2LL == 1LL) {
      ans = (ans * (a % mod_num)) % mod_num;
    }
  }
  
  return ans;
}

int main () {
  long long n = 0LL;
  long long m = 0LL;
  
  int res = 0;
  
  long long ans = 1LL;
  long long mod_num = 998244353LL;
  
  long long p = 2LL;
  long long org_m = 0LL;
  
  res = scanf("%lld", &n);
  res = scanf("%lld", &m);
  
  org_m = m;
  while (p*p <= org_m) {
    long long cnt = 0LL;
    while (m%p == 0LL) {
      m /= p;
      cnt += 1LL;
    }
    ans *= power_mod(cnt+1LL, n, mod_num)+mod_num-power_mod(cnt, n, mod_num);
    ans %= mod_num;
    p += 1LL;
  }
  
  if (m > 1LL) {
    ans *= power_mod(2LL, n, mod_num)+mod_num-1LL;
    ans %= mod_num;
  }
  
  printf("%lld\n", ans);
  return 0;
}
0