結果

問題 No.3364 Push_back Operation
コンテスト
ユーザー Carpenters-Cat
提出日時 2025-11-17 23:43:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 186 ms / 2,000 ms
コード長 485 bytes
コンパイル時間 4,232 ms
コンパイル使用メモリ 253,592 KB
実行使用メモリ 7,840 KB
最終ジャッジ日時 2025-11-17 23:43:43
合計ジャッジ時間 9,172 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint = modint998244353;
int main () {
	using ll = long long;
	ll N;
	cin >> N;
	ll h = 1;
	mint ans = 0;
	while (h * h <= N) {
		ans += mint(N / h).pow(h);
		h ++;
	}
	for (int i = h-1; i; i --) {
		ll l = max(h-1, N/(i+1)), r = min(N, N/i);
		if (i - 1) {
			mint j = i;
			ans += (j.pow(r) - j.pow(l)) / (1 - j.inv());
		} else {
			ans += r - l;
		}
	}
	cout << ans.val() << endl;
}
0