結果

問題 No.2902 ZERO!!
ユーザー HIcoderHIcoder
提出日時 2024-10-05 14:57:49
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 3,498 bytes
コンパイル時間 964 ms
コンパイル使用メモリ 123,872 KB
実行使用メモリ 26,808 KB
最終ジャッジ日時 2024-10-05 14:57:53
合計ジャッジ時間 3,274 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 41
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<string>
#include<queue>
#include<vector>
#include<cassert>
#include<random>
#include<set>
#include<map>
#include<cassert>
#include<unordered_map>
#include<bitset>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;
const int inf=1<<30;
const ll INF=1LL<<62;
typedef pair<int,ll> P;
typedef pair<int,P> PP; 
const ll MOD=998244353;



const int mod = 998244353;
struct mint {
  long long x; // typedef long long long long;
  mint(long long x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}//後ろのconstはメンバxを変更しないことを示す
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  bool operator==(const mint a) const {return a.x==x;}
  mint pow(unsigned long long int t) const {
    assert(t>=0);
    if (!t) return 1;
    //aがtで割り切れない場合には t%=(mod-1)をして良い
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};

std::istream& operator>>(std::istream& is, mint& a) { return is >> a.x;}
std::ostream& operator<<(std::ostream& os, const mint& a) { return os << a.x;}



struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};


int main(){
    ll N;
    cin>>N;
    vector<bool> used(N+1,false);
    used[0]=used[1]=true;

    vector<mint> c(50);

    vector<ll> fp(N+1,0);
    vector<mint> val,cnt;

    // vector<mint> val(N+5,1);
    // {   ll sz=0;
    //     ll n=N;
    //     while(n>0){
    //         sz+=n/2;
    //         n/=2;
    //     }
    //     cout<<"sz="<<sz<<endl;
    //     val=vector<mint>(sz+1);
    //     for(int c=1;c<=sz;c++){
    //         val[c]=1;
    //     }
    // }


    for(ll b=2;b<=N;b++){
        if(used[b]) continue;
        for(ll x=2*b;x<=N;x+=b){
            used[x]=true;
        }
        //bは素数
        // cout<<"b="<<b<<endl;
        
        ll tmpb=N;
        while(tmpb>0){
            fp[b]+=tmpb/b;
            tmpb/=b;
        }
        // cout<<"fp["<<b<<"]="<<fp[b]<<endl;
        if(b==2){
            val=vector<mint>(fp[2]+1,1);
            cnt=vector<mint>(fp[2]+1,0);
        }
        // cout<<"val[b]="<<val[b]<<endl;
        ll p=b;
        for(ll i=1;i<=fp[b];i++){
            val[i]*=(1+fp[b]/i);
            cnt[i]+=1;
        }
        // cout<<"val["<<b<<"]="<<val[b]<<endl;
    }

    mint ans=0;
    for(ll i=1;i<=fp[2];i++){
        // cout<<"i="<<i<<",val[i]="<<val[i]<<endl;
        ans+=val[i];//-cnt[i];
    }
    for(int i=1;i<=fp[2];i++){
        ans-=1;
    }
    //ans-=(fp[2]-1);//[2,N]

    cout<<ans<<endl;

}
0