結果

問題 No.3364 Push_back Operation
コンテスト
ユーザー shingo0909
提出日時 2025-11-17 21:47:48
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 372 ms / 2,000 ms
コード長 696 bytes
コンパイル時間 3,035 ms
コンパイル使用メモリ 279,812 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2025-11-17 21:48:02
合計ジャッジ時間 11,678 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 53
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <cstdlib>
#include <math.h>
#include <atcoder/modint>
using namespace std;

using ll = long long;
using mint = atcoder::modint998244353;

int main(){
    ll n;
    cin >> n;
    mint ans=0;
    ll m=sqrt(n);
    for(int i=1;i<=m;i++){
        ans+=mint(n/i).pow(i);
    }
    ll j=m+1;
    while(j<=n){
        ll l=j,r=n+1;
        while(l+1!=r){
            ll c=(l+r)/2;
            if(n/c==n/j)l=c;
            else r=c;
        }
        r=n/l;
        ll x=l-j+1;
        if(r==1){
            ans+=x;
        }else{
            ans+=mint(r).pow(j)*(1-mint(r).pow(x))/mint(1-r);
        }
        j=l+1;
    }
    cout << ans.val() << endl;
    return 0;
}
0