1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
| #include<bits/stdc++.h> #define re register typedef long long ll; template<class T> inline void read(T &x) { x=0; char ch=getchar(),t=0; while(ch<'0'||ch>'9') t|=ch=='-',ch=getchar(); while(ch>='0'&&ch<='9') x=(x<<3)+(x<<1)+(ch^48),ch=getchar(); if(t) x=-x; } template<class T,class ...T1> inline void read(T &x,T1 &...x1){ read(x),read(x1...); } template<class T> inline void write(T x) { if(x<0) putchar('-'),x=-x; if(x>9) write(x/10); putchar(x%10+'0'); } template<> inline void write(bool x){ putchar(x?'1':'0'); } template<> inline void write(char c){ putchar(c); } template<> inline void write(char *s){ while(*s!='\0') putchar(*s++); } template<> inline void write(const char *s){ while(*s!='\0') putchar(*s++); } template<class T,class ...T1> inline void write(T x,T1 ...x1){ write(x),write(x1...); } template<class T> inline bool checkMax(T &x,T y){ return x<y?x=y,1:0; } template<class T> inline bool checkMin(T &x,T y){ return x>y?x=y,1:0; } using Pir=std::pair<int,int>; #define fir first #define sec second #define Mkr std::make_pair const int MAXN=4e6+10; const int S=4e6; const int Mod=998244353; template<class T1,class T2> inline void add(T1 &x,T2 y){ x=x+y>=Mod?x+y-Mod:x+y; } ll P,ans; inline ll qPow(ll a,ll b=Mod-2) { ll res=1; for(;b;b>>=1,a=a*a%Mod) (b&1)&&(res=res*a%Mod); return res; } int pri[MAXN],Tot,phi[MAXN]; bool is[MAXN]; inline void sieve(int n) { phi[1]=1; for(int i=2;i<=n;++i) { if(!is[i]) pri[++Tot]=i,phi[i]=i-1; for(int j=1;j<=Tot&&i*pri[j]<=n;++j) { is[i*pri[j]]=1; if(i%pri[j]==0) { phi[i*pri[j]]=pri[j]*phi[i]; break; } phi[i*pri[j]]=phi[i]*(pri[j]-1); } } } std::vector<ll>vec; inline void apart(ll x) { for(ll i=2;i*i<=x;++i) if(x%i==0) vec.push_back(i),vec.push_back(x/i); if(x>1) vec.push_back(x); } inline ll getPhi(ll x) { ll res=x; for(ll i=2;i*i<=x;++i) if(x%i==0) { res=res*(i-1)/i; while(x%i==0) x/=i; } if(x>1) res=res*(x-1)/x; return res; } inline ll F(ll p,ll k) { ll delta=-1,mul=p,res=0; for(int i=1;i<=k*2;++i) { res=(res+(mul*delta%Mod+Mod)%Mod+Mod)%Mod; delta*=-1,mul=mul*p%Mod; } return (res+1)%Mod; } inline void solve(ll x) { ll ans=1; for(ll i=2;i*i<=x;++i) if(x%i==0) { ll cnt=0; while(x%i==0) ++cnt,x/=i; ans=ans*F(i,cnt)%Mod; } if(x>1) ans=ans*F(x,1)%Mod; write((ans+1)%Mod); } int main() { freopen("highpriestess.in","r",stdin); freopen("highpriestess.out","w",stdout); read(P); solve(P-1); return 0; return 0; }
|