結果

問題 No.2318 Phys Bone Maker
ユーザー 👑 chro_96chro_96
提出日時 2023-05-27 07:34:39
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 451 ms / 3,000 ms
コード長 2,425 bytes
コンパイル時間 1,175 ms
コンパイル使用メモリ 30,876 KB
実行使用メモリ 237,040 KB
最終ジャッジ日時 2023-08-26 17:40:19
合計ジャッジ時間 9,315 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
236,976 KB
testcase_01 AC 59 ms
236,840 KB
testcase_02 AC 451 ms
237,040 KB
testcase_03 AC 68 ms
236,976 KB
testcase_04 AC 72 ms
236,956 KB
testcase_05 AC 70 ms
236,960 KB
testcase_06 AC 70 ms
236,976 KB
testcase_07 AC 60 ms
236,844 KB
testcase_08 AC 70 ms
236,952 KB
testcase_09 AC 68 ms
236,928 KB
testcase_10 AC 78 ms
237,036 KB
testcase_11 AC 71 ms
236,912 KB
testcase_12 AC 78 ms
236,964 KB
testcase_13 AC 75 ms
236,964 KB
testcase_14 AC 72 ms
236,952 KB
testcase_15 AC 70 ms
236,928 KB
testcase_16 AC 71 ms
236,956 KB
testcase_17 AC 78 ms
236,972 KB
testcase_18 AC 78 ms
237,000 KB
testcase_19 AC 65 ms
236,844 KB
testcase_20 AC 73 ms
236,952 KB
testcase_21 AC 69 ms
236,976 KB
testcase_22 AC 69 ms
237,036 KB
testcase_23 AC 68 ms
236,956 KB
testcase_24 AC 76 ms
236,980 KB
testcase_25 AC 73 ms
236,900 KB
testcase_26 AC 73 ms
236,900 KB
testcase_27 AC 76 ms
236,896 KB
testcase_28 AC 68 ms
236,976 KB
testcase_29 AC 67 ms
236,840 KB
testcase_30 AC 65 ms
236,856 KB
testcase_31 AC 78 ms
236,956 KB
testcase_32 AC 76 ms
236,960 KB
testcase_33 AC 59 ms
236,856 KB
testcase_34 AC 73 ms
236,900 KB
testcase_35 AC 107 ms
236,980 KB
testcase_36 AC 249 ms
236,856 KB
testcase_37 AC 247 ms
237,032 KB
testcase_38 AC 257 ms
236,860 KB
testcase_39 AC 351 ms
236,840 KB
testcase_40 AC 346 ms
237,036 KB
testcase_41 AC 387 ms
236,896 KB
testcase_42 AC 390 ms
236,924 KB
testcase_43 AC 79 ms
237,032 KB
testcase_44 AC 115 ms
237,032 KB
testcase_45 AC 111 ms
237,040 KB
testcase_46 AC 399 ms
236,856 KB
testcase_47 AC 80 ms
236,848 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

long long gcd (long long a, long long b) {
  if (b <= 0LL) {
    return a;
  }
  
  return gcd(b, a%b);
}

int main () {
  long long n = 0LL;
  
  int res = 0;
  
  long long ans = 0LL;
  long long mod_num = 998244353LL;
  
  long long tmp = 0LL;
  long long pl[20] = {};
  long long pc[20] = {};
  int pcnt = 0;
  
  long long div[6720] = {};
  int divcnt = 0;
  
  int *e[6720] = {};
  long long *c[6720] = {};
  int ecnt[6720] = {};
  
  int e_arr[20000000] = {};
  long long c_arr[20000000] = {};
  int sum = 0;
  
  int divpcnt[6720][20] = {};
  
  long long dp[6720] = {};
  
  res = scanf("%lld", &n);
  
  tmp = n;
  for (long long p = 2LL; p*p <= n; p += 1LL) {
    if (tmp%p == 0LL) {
      pl[pcnt] = p;
      while (tmp%p == 0LL) {
        tmp /= p;
        pc[pcnt]++;
      }
      pcnt++;
    }
    if (n%p == 0LL) {
      div[divcnt] = p;
      divcnt++;
    }
  }
  
  if (tmp > 1LL) {
    pl[pcnt] = tmp;
    pc[pcnt] = 1;
    pcnt++;
  }
  
  if (divcnt <= 0) {
    printf("1\n");
    return 0;
  }
  
  if (div[divcnt-1]*div[divcnt-1] == n) {
    for (int i = 0; i < divcnt-1; i++) {
      div[2*divcnt-2-i] = n/div[i];
    }
    divcnt = 2*divcnt-1;
  } else {
    for (int i = 0; i < divcnt; i++) {
      div[2*divcnt-1-i] = n/div[i];
    }
    divcnt *= 2;
  }
  
  div[divcnt] = n;
  divcnt++;
  
  for (int i = 0; i < divcnt; i++) {
    for (int j = 0; j < pcnt; j++) {
      long long tmp = div[i];
      while (tmp%pl[j] == 0LL) {
        tmp /= pl[j];
        divpcnt[i][j]++;
      }
    }
  }
  
  for (int i = 0; i < divcnt; i++) {
    e[i] = e_arr+sum;
    c[i] = c_arr+sum;
    for (int j = i+1; j < divcnt; j++) {
      if (div[j]%div[i] == 0LL) {
        e[i][ecnt[i]] = j;
        c[i][ecnt[i]] = 1LL;
        for (int k = 0; k < pcnt; k++) {
          if (divpcnt[i][k] == divpcnt[j][k]) {
            c[i][ecnt[i]] *= (long long)(divpcnt[i][k]+1);
            c[i][ecnt[i]] %= mod_num;
          }
        }
        ecnt[i]++;
      }
    }
    sum += ecnt[i];
  }
  
  for (int i = 0; i < divcnt; i++) {
    dp[i] = 1LL;
  }
  
  while (dp[divcnt-1] > 0LL) {
    ans += dp[divcnt-1]%mod_num;
    for (int i = divcnt-1; i >= 0; i--) {
      if (dp[i] > 0LL) {
        dp[i] %= mod_num;
        for (int j = 0; j < ecnt[i]; j++) {
          dp[e[i][j]] += dp[i]*c[i][j];
        }
      }
      dp[i] = 0LL;
    }
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0