結果

問題 No.2902 ZERO!!
ユーザー eve__fuyuki
提出日時 2024-10-02 14:08:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 68 ms / 2,000 ms
コード長 931 bytes
コンパイル時間 2,171 ms
コンパイル使用メモリ 203,992 KB
最終ジャッジ日時 2025-02-24 14:28:12
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void fast_io() {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
}

#include <atcoder/modint>
using mint = atcoder::modint998244353;
int main() {
	fast_io();
	int n;
	cin >> n;
	vector<int> factors;
	{
		bool is_p[n + 1];
		for (int i = 0; i <= n; i++) is_p[i] = true;
		is_p[0] = is_p[1] = false;
		for (int i = 2; i <= n; i++) {
			if (is_p[i]) {
				for (int j = i * 2; j <= n; j += i) {
					is_p[j] = false;
				}
				int cnt = 0;
				for (int j = i;; j *= i) {
					cnt += n / j;
					if (n / j < i) break;
				}
				factors.push_back(cnt);
			}
		}
	}
	map<int, int> cnt;
	for (int j : factors) {
		cnt[j]++;
	}
	int M = factors[0];
	mint ans = 0;
	for (int i = 1; i <= M; i++) {
		mint tmp = 1;
		auto it = cnt.lower_bound(i);
		while (it != cnt.end()) {
			tmp *= mint(it->first / i + 1).pow(it->second);
			it++;
		}
		ans += tmp - 1;
	}
	cout << ans.val() << endl;
}
0