| 比赛 |
寒假集训4 |
评测结果 |
WWEEEEEEEE |
| 题目名称 |
数据结构题 |
最终得分 |
0 |
| 用户昵称 |
PXCZM |
运行时间 |
2.091 s |
| 代码语言 |
C++ |
内存使用 |
4.01 MiB |
| 提交时间 |
2026-02-28 11:43:16 |
显示代码纯文本
#include <bits/stdc++.h>
#define lowbit(i) i&(-i)
#define ll long long
using namespace std;
ll n,m;
ll a[100000];
void add(ll x,ll y)
{
for(int i=x;i<100000;i+=lowbit(i)) a[i]+=y;
}
ll query(ll x)
{
ll ans=0;
for(int i=x;i;i-=lowbit(i)) ans+=a[i];
return ans;
}
ll ksm(ll x,ll y,ll mod)
{
ll ans=1;
while(y)
{
if(y&1) ans=ans*x%mod;
x=x*x%mod;
y=y>>1;
}
return ans;
}
int main()
{
freopen("sjjgt.in","r",stdin);
freopen("sjjgt.out","w",stdout);
ios::sync_with_stdio(false);
cin.tie(nullptr);cout.tie(nullptr);
cin>>n>>m;
for(int i=1;i<=n;i++)
{
ll tmp;cin>>tmp;
add(i,tmp);
add(i+1,-tmp);
}
while(m--)
{
int op,l,r;
ll x;
cin>>op>>l>>r>>x;
if(op==1)
{
add(r,x);
add(l+1,x);
}
else
{
ll tmp=1;
for(int i=l+1;i<=r;i++) tmp=tmp*(query(i)%x)%x;
cout<<ksm((query(l)%x),tmp,x)<<'\n';
}
}
return 0;
}