不难看出就是要先求区间积,再求这个区间积的(varphi)
因为(varphi(x)=x imesfrac{p_1-1}{p_1} imesfrac{p_2-1}{p_2} imes ...),又因为质数总共只有(60)个,我们可以用一个(long long)来压位,表示某一个质因子是否出现过,那么用线段树维护这个东西,顺便维护区间乘积即可
因为模数是质数,可以预处理逆元
//minamoto
#include<bits/stdc++.h>
#define R register
#define ll long long
#define ls (p<<1)
#define rs (p<<1|1)
#define fp(i,a,b) for(R int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(R int i=a,I=b-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
R int res,f=1;R char ch;
while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
return res*f;
}
char sr[1<<21],z[20];int C=-1,Z=0;
inline void Ot(){fwrite(sr,1,C+1,stdout),C=-1;}
void print(R int x){
if(C>1<<20)Ot();if(x<0)sr[++C]='-',x=-x;
while(z[++Z]=x%10+48,x/=10);
while(sr[++C]=z[Z],--Z);sr[++C]='
';
}
const int N=1e5+5,P=19961993;
const int p[]={2,3,5,7,11,13,17,19,23,29,
31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,
127,131,137,139,149,151,157,163,167,173,
179,181,191,193,197,199,211,223,227,229,
233,239,241,251,257,263,269,271,277,281};
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
R int res=1;
for(;y;y>>=1,x=mul(x,x))if(y&1)res=mul(res,x);
return res;
}
int n=1e5,m,x,l,r,sum[N<<2],inv[65],res;
ll s[N<<2],rrs;
void build(int p,int l,int r){
if(l==r)return (void)(sum[p]=3,s[p]=2);
int mid=(l+r)>>1;
build(ls,l,mid),build(rs,mid+1,r);
sum[p]=mul(sum[ls],sum[rs]);
s[p]=s[ls]|s[rs];
}
void update(int p,int l,int r,int x,int vva,ll v){
if(l==r)return (void)(sum[p]=vva,s[p]=v);
int mid=(l+r)>>1;
x<=mid?update(ls,l,mid,x,vva,v):update(rs,mid+1,r,x,vva,v);
sum[p]=mul(sum[ls],sum[rs]);
s[p]=s[ls]|s[rs];
}
void query(int p,int l,int r,int ql,int qr){
if(ql<=l&&qr>=r)return (void)(rrs|=s[p],res=mul(res,sum[p]));
int mid=(l+r)>>1;
if(ql<=mid)query(ls,l,mid,ql,qr);
if(qr>mid)query(rs,mid+1,r,ql,qr);
}
int main(){
// freopen("testdata.in","r",stdin);
m=read(),build(1,1,n);
fp(i,0,59)inv[i]=ksm(p[i],P-2);
while(m--){
x=read(),l=read(),r=read();
if(x==0){
rrs=0,res=1,query(1,1,n,l,r);
fp(i,0,59)if(rrs>>i&1)res=mul(res,mul(p[i]-1,inv[i]));
print(res);
}else{
rrs=0,res=r;
fp(i,0,59)if(res%p[i]==0)rrs|=(1ll<<i);
update(1,1,n,l,res,rrs);
}
}return Ot(),0;
}