結果

問題 No.2318 Phys Bone Maker
ユーザー shobonvipshobonvip
提出日時 2023-05-26 21:47:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,438 ms / 3,000 ms
コード長 1,319 bytes
コンパイル時間 4,413 ms
コンパイル使用メモリ 267,600 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 11:06:50
合計ジャッジ時間 15,792 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1,438 ms
4,380 KB
testcase_03 AC 6 ms
4,380 KB
testcase_04 AC 8 ms
4,376 KB
testcase_05 AC 8 ms
4,380 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 7 ms
4,376 KB
testcase_10 AC 12 ms
4,376 KB
testcase_11 AC 9 ms
4,376 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 12 ms
4,376 KB
testcase_14 AC 9 ms
4,376 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 11 ms
4,380 KB
testcase_17 AC 11 ms
4,384 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 5 ms
4,380 KB
testcase_20 AC 10 ms
4,380 KB
testcase_21 AC 8 ms
4,376 KB
testcase_22 AC 7 ms
4,376 KB
testcase_23 AC 9 ms
4,376 KB
testcase_24 AC 10 ms
4,380 KB
testcase_25 AC 11 ms
4,376 KB
testcase_26 AC 9 ms
4,376 KB
testcase_27 AC 10 ms
4,380 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 15 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 10 ms
4,380 KB
testcase_35 AC 122 ms
4,380 KB
testcase_36 AC 574 ms
4,376 KB
testcase_37 AC 631 ms
4,376 KB
testcase_38 AC 702 ms
4,380 KB
testcase_39 AC 897 ms
4,380 KB
testcase_40 AC 984 ms
4,376 KB
testcase_41 AC 1,067 ms
4,376 KB
testcase_42 AC 1,175 ms
4,376 KB
testcase_43 AC 17 ms
4,376 KB
testcase_44 AC 327 ms
4,376 KB
testcase_45 AC 291 ms
4,376 KB
testcase_46 AC 1,351 ms
4,380 KB
testcase_47 AC 23 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;

typedef modint998244353 mint;
typedef long long ll;

// makediv
vector<ll> makediv(ll n){
	vector<ll> ld, ud;
	for (ll i=1; i*i<=n; i++){
		if (n%i == 0){
			ld.push_back(i);
			if (i != n/i){
				ud.push_back(n/i);
			}
		}
	}
	reverse(ud.begin(), ud.end());
	ld.insert(ld.end(), ud.begin(), ud.end());
	return ld;
}
// -----

vector<pair<ll,int>> pfact(ll n){
	vector<pair<ll,int>> ret;
	for (ll i=2; i*i<=n; i++){
		if (n%i == 0){
			int cnt = 0;
			while (n%i == 0){
				n /= i;
				cnt++;
			}
			ret.push_back(pair(i, cnt));
		}
	}
	if (n > 1) ret.push_back(pair(n, 1));
	return ret;
}


int main(){
	ll n; cin >> n;
	vector<pair<ll,int>> pf = pfact(n);
	vector<ll> g = makediv(n);
	int m = g.size();
	vector<mint> dp(m);
	dp[0] = 1;
	for (int i=0; i<m; i++){
		for (int j=0; j<i; j++){
			if (g[i] % g[j] == 0){
				mint val = 1;
				for (auto [p,c]: pf){
					int cnt_i = 0, cnt_j = 0;
					{
						ll k = g[i];
						while (k % p == 0){
							k /= p;
							cnt_i++;
						}
					}
					{
						ll k = g[j];
						while (k % p == 0){
							k /= p;
							cnt_j++;
						}
					}
					if (cnt_i == cnt_j){
						val *= cnt_i + 1;
					}
				}
				dp[i] += dp[j] * val;
			}
		}
	}
	cout << dp[m-1].val() << endl;

}
0