单点更新,更新时先除去 原来的数,因为有去摸,可以用乘上逆元代替。
//============================================================================
// Name : A.cpp
// Author : L_Ecry
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================ #include <iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define N 50050
#define MOD 1000000007
#define LL long long
using namespace std;
LL value[N*];
int a[N];
int n;
int extgcd(int a,int b,int &x,int &y)
{
int t,d;
if(b==){
x=;y=;
return a;
}
d=extgcd(b,a%b,x,y);
t=x;
x=y;
y=t-a/b*y;
return d;
}
int invmod(int a,int n)
{
int x,y;
if(extgcd(a,n,x,y)!=)return -;
return (x%n+n)%n;
}
void build(int l,int r,int i)
{
if(l==r){
value[i]=a[l];
return;
}
int mid=(l+r)>>;
int lson=(i<<),rson=(i<<|);
build(l,mid,lson);
build(mid+,r,rson);
value[i]=(value[lson]*value[rson])%MOD;
}
void update(int l,int r,int p,int va,int i)
{
if(l==r)
{
value[i]=va;
return;
}
value[i]=(value[i]*invmod(a[p],MOD))%MOD;
value[i]=(value[i]*va)%MOD;
int mid=(l+r)>>;
if(p<=mid)update(l,mid,p,va,i<<);
else update(mid+,r,p,va,i<<|);
}
LL query(int l,int r,int pl,int pr,int i)
{
if(l==pl&&r==pr)
return value[i];
int mid=(l+r)>>;
if(mid>=pr)return query(l,mid,pl,pr,i<<);
else if(pl>mid)return query(mid+,r,pl,pr,i<<|);
else {
return (query(l,mid,pl,mid,i<<)*query(mid+,r,mid+,pr,i<<|))%MOD;
}
}
void init()
{
scanf("%d",&n);
for(int i=;i<=n;++i)
scanf("%d",&a[i]);
build(,n,);
}
void solve()
{
int q;
scanf("%d",&q);
while(q--)
{
int x,y,z;
scanf("%d%d%d",&x,&y,&z);
if(x==)
{
update(,n,y,z,);
a[y]=z;
}else
{
printf("%lld\n",query(,n,y,z,));
}
}
}
int main() {
int tt;
scanf("%d",&tt);
while(tt--)
{
init();
solve();
}
return ;
}