結果

問題 No.2318 Phys Bone Maker
ユーザー 👑 chro_96chro_96
提出日時 2023-05-26 23:11:22
言語 C
(gcc 12.3.0)
結果
MLE  
実行時間 -
コード長 2,124 bytes
コンパイル時間 1,401 ms
コンパイル使用メモリ 30,576 KB
実行使用メモリ 812,972 KB
最終ジャッジ日時 2023-08-26 13:36:30
合計ジャッジ時間 3,648 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
権限があれば一括ダウンロードができます

ソースコード

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 div[6720] = {};
  int divcnt = 0;
  
  long long e[6720][6720] = {};
  
  int ee[6720][6720] = {};
  long long c[6720][6720] = {};
  int ecnt[6720] = {};
  
  long long dp[6720] = {};
  
  res = scanf("%lld", &n);
  
  for (long long p = 2LL; p*p <= n; p += 1LL) {
    if (n%p == 0LL) {
      div[divcnt] = p;
      divcnt++;
    }
  }
  
  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-i-2] = n/div[i];
    }
    divcnt = 2*divcnt-1;
  } else {
    for (int i = 0; i < divcnt; i++) {
      div[2*divcnt-i-1] = n/div[i];
    }
    divcnt = 2*divcnt;
  }
  
  div[divcnt] = n;
  divcnt++;
  
  for (int i = 0; i < divcnt; i++) {
    for (int j = 0; j < divcnt; j++) {
      if (div[i]%div[j] != 0LL && div[j]%div[i] != 0LL) {
        long long tmp = div[i]/gcd(div[i], div[j]);
        tmp *= div[j];
        if (tmp > div[i]) {
          int idx[2] = { i+1, divcnt };
          while (idx[1]-idx[0] > 1) {
            int nxt = (idx[0]+idx[1])/2;
            if (tmp < div[nxt]) {
              idx[1] = nxt;
            } else {
              idx[0] = nxt;
            }
          }
          e[i][idx[0]] += 1LL;
        }
      }
    }
  }
  
  for (int i = 0; i < divcnt; i++) {
    for (int j = i+1; j < divcnt; j++) {
      if (e[i][j] > 0LL) {
        ee[i][ecnt[i]] = j;
        c[i][ecnt[i]] = e[i][j];
        ecnt[i]++;
      }
    }
  }
  
  for (int i = 0; i < divcnt; i++) {
    dp[i] = 1LL;
  }
  
  while (dp[divcnt-1] > 0LL) {
    ans += dp[divcnt-1];
    for (int i = divcnt-1; i >= 0; i--) {
      if (dp[i] > 0LL) {
        for (int j = 0; j < ecnt[i]; j++) {
          dp[ee[i][j]] += dp[i]*c[i][j];
          dp[ee[i][j]] %= mod_num;
        }
      }
      dp[i] = 0LL;
    }
  }
  
  printf("%lld\n", ans%mod_num);
  return 0;
}
0