数论v2

时间:2023-03-09 04:39:45
数论v2
#include <cmath>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define mod 1000000007
#define maxint 2147483648
#define nc1
#define rg register
#define rg1
#define rg2
#define rg3
typedef long long ll;
namespace basicmath{
inline ll mp(ll a,ll b,ll p){
if(p<3037000000ll) return a*b%p;
#ifdef nc1
if(p<1099511627776ll) return (((a*(b>>20)%p)<<20)+(a*(b&((1<<20)-1))))%p;
#endif
ll d=(ll)(a*(long double)b/p+0.5); ll ret=(a*b-d*p)%p;
if (ret<0) ret+=p; else if (ret>=p) ret-=p;
return ret;
}
inline ll fp(int a,int b,int p){ a%=p,b%=p-1; int ans=1; for(;b;b>>=1,a=(ll)a*a%p) if(b&1) ans=(ll)ans*a%p; return ans; }
inline ll fp(ll a,ll b,ll p){ a%=p,b%=p-1; ll ans=1ll; for(;b;b>>=1,a=mp(a,a,p)) if(b&1) ans=mp(a,ans,p); return ans; }
template<int max=10000007> struct sieve{
int q[max+5]; int pr[max/4],pl,rxsiz;
inline void generate(rg3 int n=max){ //// rg3
for(rg1 int i=2;i<=n;++i){ //// rg1
if(!q[i]) pr[pl++]=i,q[i]=i;
for(rg2 int j=
}
}
}
}
int main(){
return 0;
}