結果

問題 No.2318 Phys Bone Maker
ユーザー ococonomy1ococonomy1
提出日時 2023-05-27 11:54:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,341 ms / 3,000 ms
コード長 3,113 bytes
コンパイル時間 1,443 ms
コンパイル使用メモリ 121,480 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 20:02:01
合計ジャッジ時間 12,064 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1,341 ms
4,376 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 8 ms
4,384 KB
testcase_06 AC 8 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 7 ms
4,380 KB
testcase_09 AC 6 ms
4,380 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 9 ms
4,380 KB
testcase_12 AC 11 ms
4,376 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 7 ms
4,376 KB
testcase_16 AC 9 ms
4,380 KB
testcase_17 AC 11 ms
4,376 KB
testcase_18 AC 11 ms
4,376 KB
testcase_19 AC 5 ms
4,376 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 7 ms
4,380 KB
testcase_22 AC 6 ms
4,376 KB
testcase_23 AC 8 ms
4,376 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 10 ms
4,380 KB
testcase_26 AC 9 ms
4,376 KB
testcase_27 AC 9 ms
4,376 KB
testcase_28 AC 6 ms
4,376 KB
testcase_29 AC 6 ms
4,376 KB
testcase_30 AC 7 ms
4,380 KB
testcase_31 AC 11 ms
4,376 KB
testcase_32 AC 14 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 9 ms
4,380 KB
testcase_35 AC 120 ms
4,376 KB
testcase_36 AC 536 ms
4,376 KB
testcase_37 AC 590 ms
4,380 KB
testcase_38 AC 638 ms
4,376 KB
testcase_39 AC 831 ms
4,376 KB
testcase_40 AC 899 ms
4,380 KB
testcase_41 AC 991 ms
4,384 KB
testcase_42 AC 1,110 ms
4,380 KB
testcase_43 AC 16 ms
4,380 KB
testcase_44 AC 298 ms
4,376 KB
testcase_45 AC 267 ms
4,376 KB
testcase_46 AC 1,253 ms
4,376 KB
testcase_47 AC 22 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <cassert>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <complex>
#define _USE_MATH_DEFINES
#include <math.h>
using namespace std;
using lg = long long;
using pii = pair<int, int>;
using pll = pair<lg, lg>;
#define TEST clog << "TEST" << endl
#define IINF 2147483647
#define LLINF 9223372036854775807LL
#define AMARI 998244353
//#define AMARI 1000000007
#define TEMOTO ((sizeof(long double) == 16) ? false : true)
#define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000)
#define el '\n'
#define El '\n'

long long ococo_gcd(long long a, long long b) {
    if (a < b) {
        long long kari = b;
        b = a;
        a = kari;
    }
    long long ans = a;
    while (a % b) {
        long long kari = b;
        b = a % b;
        a = kari;
    }
    return min(a, b);
}

lg lcm(lg a, lg b) {
    a /= ococo_gcd(a, b);
    return (a * b);
}

#define MULTI_TEST_CASE false
void solve(void) {
    lg n;
    cin >> n;
    lg nc = n;
    vector<lg> yakusuu;
    for (lg i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            yakusuu.push_back(n / i);
            if (i * i != n)yakusuu.push_back(i);
        }
    }
    sort(yakusuu.begin(), yakusuu.end());
    int m = yakusuu.size();

    map<lg,int> soinsuu;
    for (lg i = 2; i * i <= n; i++) {
        while (n % i == 0) {
            soinsuu[i]++;
            n /= i;
        }
    }
    if (n != 1)soinsuu[n]++;

    vector<lg> dp(m, 0);
    dp[0] = 1;
    for (int i = 1; i < m; i++) {
        for (int j = 0; j < i; j++) {
            //yakusuu[j]→yakusuu[i]が何通りあるか
            if (yakusuu[i] % yakusuu[j] != 0)continue;
            lg temp = 1;
            for (map<lg, int>::iterator it = soinsuu.begin(); it != soinsuu.end(); it++) {
                //yakusuu[i]とyakusuu[j]がそれぞれit->firstで何回割れるか
                //毎回計算するとヤバいかもしれないので、TLEになったら前計算する
                lg ci = yakusuu[i], cj = yakusuu[j];
                int cnti = 0, cntj = 0;
                while (ci % it->first == 0) {
                    ci /= it->first;
                    cnti++;
                }
                while (cj % it->first == 0) {
                    cj /= it->first;
                    cntj++;
                }
                if (cnti == cntj)temp *= (cnti + 1);
                temp %= AMARI;
            }
            //clog << yakusuu[i] << ' ' << yakusuu[j] << ' ' << temp << el;
            dp[i] += temp * dp[j];
            dp[i] %= AMARI;
        }
    }
    //for (int i = 0; i < m; i++)clog << dp[i] << ' ';
    //clog << El;
    cout << dp[m - 1] << El;
    return;
}

void calc(void) {
    return;
}

int main(void) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    calc();
    int t = 1;
    if (MULTI_TEST_CASE)cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}
0