結果

問題 No.2902 ZERO!!
ユーザー i_am_noob
提出日時 2025-07-03 23:25:33
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 1,062 bytes
コンパイル時間 2,131 ms
コンパイル使用メモリ 198,688 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2025-07-03 23:25:38
合計ジャッジ時間 4,228 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using pii=pair<int,int>;

#define all(a) a.begin(),a.end()
#define pb push_back
#define sz(a) ((int)a.size())

const int N=1000005,mod=998244353;
int add(int x, int y){x+=y; if(x>=mod) x-=mod; return x;}
int sub(int x, int y){x-=y; if(x<0) x+=mod; return x;}
int mul(int x, int y){return ((ll)x)*y%mod;}

int n;
bool isp[N];

void amano_hina_is_the_goat(){
    cin >> n;
    for(int i=2; i<=n; ++i) isp[i]=1;
    vector<int> vec;
    for(int i=2; i<=n; ++i) if(isp[i]){
        for(int j=i*2; j<=n; j+=i) isp[j]=0;
        int tot=0;
        for(ll cur=i; cur<=n; cur*=i) tot+=n/cur;
        vec.pb(tot);
    }
    int res=0;
    for(int i=1; i<=vec[0]; ++i){
        int de=1;
        for(int j=0; j<sz(vec)&&vec[j]>=i; ++j) de=mul(de,vec[j]/i+1);
        de=sub(de,1);
        res=add(res,de);
    }
    cout << res << "\n";
}

signed main(){
    ios_base::sync_with_stdio(0),cin.tie(0);
    cout << fixed << setprecision(20);
    int t=1; //cin >> t;
    while(t--) amano_hina_is_the_goat();
}
0