2012年8月10日

poj3468 A Simple Problem with Integers

摘要: 1 #include<stdio.h> 2 #define N 100010 3 struct node{ 4 int l,r; 5 __int64 inc,sum;//注意要定义为__int64型 6 }tree[3*N]; 7 int num[N]; 8 void build(int l,int r,int i)//建立线段树 9 {10 tree[i].l=l;11 tree[i].r=r;12 tree[i].inc=0;13 if(l==r){14 tree[i].sum=num[l];//叶子节点赋值 15 ... 阅读全文

posted @ 2012-08-10 20:41 小花熊 阅读(148) 评论(0) 推荐(0) 编辑

poj2182 Lost Cows

摘要: 1 #include<stdio.h> 2 #define N 8010 3 struct node{ 4 int l,r; 5 int len;//len用来存放某一段数据的个数 6 }tree[N<<1]; 7 int s[N],result[N]; 8 void build(int l,int r,int i) 9 {10 tree[i].l=l;11 tree[i].r=r;12 tree[i].len=r-l+1; 13 if(l==r) return;14 int mid=(l+r)>>1;15 build(l,m... 阅读全文

posted @ 2012-08-10 15:04 小花熊 阅读(333) 评论(0) 推荐(0) 编辑

hdu1754 I Hate It

摘要: 1 #include<cstdio> 2 #include<cmath> 3 #include<iostream> 4 #define MAX 200010 5 using namespace std; 6 struct node{ 7 int l,r; 8 int max; 9 }tree[3*MAX];//三倍就差不多了10 int s[MAX];11 void build(int l,int r,int i)//负责建树 12 {13 tree[i].l=l;14 tree[i].r=r;15 if(l==r){16 tree[i... 阅读全文

posted @ 2012-08-10 11:00 小花熊 阅读(157) 评论(0) 推荐(0) 编辑

导航