hdu 5475 线段树
来源:互联网 发布:苹果电脑设计软件免费 编辑:程序博客网 时间:2024/06/04 23:26
#include<iostream>#include<cstdio>#include<cstdlib>#include<vector>#include<cmath>#include<string>#include<algorithm>#include<set>#include<map>#include<cstring>#include<queue>#include<stack>//#include<>using namespace std;typedef long long ll;const int MAXN=100000;struct node{ ll ji; int l,r;}tree[MAXN*4];int Q,M;void Build(int pos,int l,int r){ /* for(int i=0;i<MAXN*4;i++) { tree[i].ji=1; } */ tree[pos].l=l; tree[pos].r=r; tree[pos].ji=1; int mid=(l+r)/2; if(l==r) { return ; } Build(pos*2,l,mid); Build(pos*2+1,mid+1,r);}void update(int pos,int k,ll p){ int L=tree[pos].l; int R=tree[pos].r; int mid=(L+R)/2; if(L==R) { tree[pos].ji=p; return; } else if(k<=mid) { update(pos*2,k,p); } else if(k>=mid+1) { update(pos*2+1,k,p); } tree[pos].ji=((tree[pos*2].ji%M)*(tree[pos*2+1].ji%M))%M;}int main(){ int T,t=1; scanf("%d",&T); while(T--) { printf("Case #%d:\n",t++); scanf("%d%d",&Q,&M); Build(1,1,Q); int n=1; for(int i=0;i<Q;i++) { int x; scanf("%d",&x); if(x==1) { ll y; scanf("%I64d",&y); update(1,n,y); printf("%I64d\n",tree[1].ji); } else { int p; scanf("%d",&p); update(1,p,1); printf("%I64d\n",tree[1].ji); } n++; } }return 0;}
0 0
- hdu 5475 线段树
- hdu 5475(线段树)
- HDU 5475 平衡树/线段树
- hdu 5475 An easy problem(线段树)
- hdu 5475 An easy problem 线段树
- hdu 5475 An easy problem (线段树)
- HDU-5475-An easy problem【线段树】
- HDU 5475 线段树 + 乘法+取模
- hdu 5475(线段树(锻炼思维))
- hdu 1754 线段树
- hdu 1754 线段树
- HDU 1698 线段树
- hdu 1754 线段树
- 【线段树】hdu 1754
- hdu-1166 线段树
- HDU-2688 线段树
- HDU 4027 线段树
- HDU-1166 线段树
- codevs月赛 奶牛的身高
- 《剑指Offer》面试题:三组对面和分别相等的正方体
- Apache服务器的安装与配置
- PostgreSQL的JDBC访问
- UIImage转Md5
- hdu 5475 线段树
- ARM 体系 CPU 的 7 种工作模式 和 2 种工作状态
- Android tips
- 十一返乡行
- JDK并发工具类源码学习系列——ConcurrentHashMap
- 又是一个第一次,随便写点什么吧。
- Java集合框架
- HDU 1317 XYZZ(Floyd(传递闭包)+bellmanfd(判断正权环))
- linux中解压rar文件