线段数_HDU_3074
来源:互联网 发布:xp系统32位java下载 编辑:程序博客网 时间:2024/05/22 22:42
区间求积,暴int
#include<iostream>#include<cstdio>#define Mod 1000000007const int maxn = 50050;using namespace std;__int64 tree[maxn<<2];void work(int rt){ tree[rt] =(( tree[rt<<1]%Mod) *(tree[rt<<1|1]%Mod))%Mod;}void build(int l, int r, int rt){ if(l == r) { scanf("%d",&tree[rt]); return; } int mid = (l+r)>>1; build(l,mid,rt<<1); build(mid+1,r,rt<<1|1); work(rt);}void updata(int w,int val ,int l, int r, int rt){ if(l == r) { tree[rt] = val; return; } int mid = (l+r)>>1; if(w<=mid) updata(w,val,l,mid,rt<<1); else updata(w,val,mid+1,r,rt<<1|1); work(rt);}__int64 query(int x, int y, int l,int r, int rt){ if(x<=l&&r<=y) { return tree[rt]; } __int64 ans = 1; int mid = (l+r)>>1; if(x<=mid) ans = (ans*query(x,y,l,mid,rt<<1))%Mod; if(mid<y) ans = (ans*query(x,y,mid+1,r,rt<<1|1))%Mod; return ans;}int main(){ int t,n,m,k,a,b; scanf("%d",&t); while(t--) { scanf("%d",&n); build(1,n,1); scanf("%d",&m); while(m--) { scanf("%d%d%d",&k,&a,&b); if(k == 0) printf("%I64d\n",query(a,b,1,n,1)%Mod); else updata(a,b,1,n,1); } } return 0;}
0 0
- 线段数_HDU_3074
- poj-3264 线段数
- GSS1 线段数
- 线段数应用(poj2828)
- 线段数_HDU_1166
- 线段数求和模板
- 线段数模板
- 【例题】【线段数】lazy_
- 线段数专题
- 线段数总结
- 线段数应用(poj2828)
- [线段数]hdu 4366 Successor
- hdu 4107 Gangster 线段数
- poj2299(逆序数+线段树)
- 线段树_逆序数
- 线段树---求逆序数
- 线段数(单点更新)
- hdu1394 逆序数-线段树
- C#高级编程五十九天----集合的性能
- hdu-1022 Train Problem I (栈的简单应用)
- Objective-C 省市区 字典 封装
- 我在无限互联学习记录连载1
- 杭电1870愚人节礼物 技巧性代码VS用栈代码
- 线段数_HDU_3074
- OJ网站
- 我的登山鞋
- 2000 ASCII码排序
- 极简音乐播放器(一)
- 用VS2013编译FFMPEG232
- 每天一个小知识点15(Angularjs总结三)
- Factorial Trailing Zeroes
- ajax如果是json方式,接收页面echo出的变量一定要有json_encode()处理,html页面的返回函数success才能正常alert出这个变量