###### 离线专题学习

hdu 4288

1ikai[i%5=3]

sum[rt][i]=sum[lrt][i]+sum[rrt][5((num[lrt]i1)%5+5)%51]

#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")

using namespace std;
#define   MAX           100005
#define   MAXN          500005
#define   maxnode       105
#define   sigma_size    2
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   lrt           rt<<1
#define   rrt           rt<<1|1
#define   middle        int m=(r+l)>>1
#define   LL            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   bits(a)       __builtin_popcount(a)
#define   mk            make_pair
#define   limit         10000

//const int    prime = 999983;
const int    INF   = 0x3f3f3f3f;
const LL     INFF  = 0x3f3f;
const double pi    = acos(-1.0);
const double inf   = 1e18;
const double eps   = 1e-9;
const LL     mod   = 1e9+7;
const ull    mx    = 1333333331;

/*****************************************************/
inline void RI(int &x) {
char c;
while((c=getchar())<'0' || c>'9');
x=c-'0';
while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
/*****************************************************/
char op[MAX][10];
int a[MAX];
int b[MAX];
LL sum[MAX<<2][5];
int num[MAX<<2];
void build(int l,int r,int rt){
num[rt]=0;
for(int i=0;i<5;i++) sum[rt][i]=0;
if(l==r) return;
middle;
build(lson);
build(rson);
}

void pushup(int rt){
for(int i=0;i<5;i++)
sum[rt][i]=sum[lrt][i]+sum[rrt][5-((num[lrt]-i-1)%5+5)%5-1];
}
void update(int l,int r,int rt,int pos,int d,int v){
num[rt]+=v;
if(l==r){
sum[rt][0]+=d;
return;
}
middle;
if(pos<=m) update(lson,pos,d,v);
else update(rson,pos,d,v);
pushup(rt);
}
int main(){
//freopen("test.txt","r",stdin);
int n;
while(~scanf("%d",&n)){
int tmp=0;
for(int i=0;i<n;i++){
scanf("%s",op[i]);
if(op[i][0]!='s'){
scanf("%d",&a[i]);
b[tmp++]=a[i];
}
}
build(1,n,1);
sort(b,b+tmp);
int tot=unique(b,b+tmp)-b;
for(int i=0;i<n;i++){
int pos=lower_bound(b,b+tot,a[i])-b+1;
if(op[i][0]=='a') update(1,n,1,pos,a[i],1);
else if(op[i][0]=='d') update(1,n,1,pos,-a[i],-1);
else printf("%I64d\n",sum[1][2]);
}
}
return 0;
}


hdu 4417

#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#pragma comment(linker,"/STACK:102400000,102400000")

using namespace std;
#define   MAX           100005
#define   MAXN          500005
#define   maxnode       105
#define   sigma_size    2
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   lrt           rt<<1
#define   rrt           rt<<1|1
#define   middle        int m=(r+l)>>1
#define   LL            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   bits(a)       __builtin_popcount(a)
#define   mk            make_pair
#define   limit         10000

//const int    prime = 999983;
const int    INF   = 0x3f3f3f3f;
const LL     INFF  = 0x3f3f;
const double pi    = acos(-1.0);
const double inf   = 1e18;
const double eps   = 1e-9;
const LL     mod   = 1e9+7;
const ull    mx    = 1333333331;

/*****************************************************/
inline void RI(int &x) {
char c;
while((c=getchar())<'0' || c>'9');
x=c-'0';
while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
/*****************************************************/

struct num{
int a,pos;
bool operator < (const num &b) const{
return a<b.a;
}
}pp[MAX];
struct Node{
int l,r,h,id,ans;
}p[MAX];
bool cmp1(Node a,Node b){
return a.h<b.h;
}
bool cmp2(Node a,Node b){
return a.id<b.id;
}
int sum[MAX<<2];
void build(int l,int r,int rt){
sum[rt]=0;
if(l==r) return ;
middle;
build(lson);
build(rson);
}

void pushup(int rt){
sum[rt]=sum[lrt]+sum[rrt];
}

void update(int l,int r,int rt,int pos){
if(l==r){
sum[rt]++;
return;
}
middle;
if(pos<=m) update(lson,pos);
else update(rson,pos);
pushup(rt);
}

int query(int l,int r,int rt,int L,int R){
if(L<=l&&r<=R) return sum[rt];
middle;
int ans=0;
if(L<=m) ans+=query(lson, L,R);
if(R>m) ans+=query(rson,L,R);
return ans;
}

int main(){
//freopen("test.txt","r",stdin);
int t,kase=0;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
for(int i=0;i<n;i++){
int a;
scanf("%d",&a);
pp[i]=(num){a,i+1};
}
sort(pp,pp+n);
for(int i=0;i<m;i++){
int l,r,h;
scanf("%d%d%d",&l,&r,&h);
p[i]=(Node){l+1,r+1,h,i,0};
}
sort(p,p+m,cmp1);
int ret=0;
build(1,n,1);
for(int i=0;i<m;i++){
while(pp[ret].a<=p[i].h&&ret<n){
update(1,n,1,pp[ret].pos);
ret++;
}
p[i].ans=query(1,n,1,p[i].l,p[i].r);
}
sort(p,p+m,cmp2);
kase++;
printf("Case %d:\n",kase);
for(int i=0;i<m;i++) printf("%d\n",p[i].ans);
}
return 0;
}

hdu 3874
http://acm.hdu.edu.cn/showproblem.php?pid=3874

#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")

using namespace std;
#define   MAX           50005
#define   MAXN          6005
#define   maxnode       15
#define   sigma_size    30
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   lrt           rt<<1
#define   rrt           rt<<1|1
#define   middle        int m=(r+l)>>1
#define   LL            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   bits(a)       __builtin_popcount(a)
#define   mk            make_pair
#define   limit         10000

//const int    prime = 999983;
const int    INF   = 0x3f3f3f3f;
const LL     INFF  = 0x3f3f;
const double pi    = acos(-1.0);
//const double inf   = 1e18;
const double eps   = 1e-8;
const LL    mod    = 1e9+7;
const ull    mx    = 133333331;

/*****************************************************/
inline void RI(int &x) {
char c;
while((c=getchar())<'0' || c>'9');
x=c-'0';
while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
/*****************************************************/

struct Node{
int l,r,id;
bool operator < (const Node&e)const{
return r>e.r;
}
}p[MAX*4];
LL ans[MAX*4];
int a[MAX];
int pos[1000005];
int pre[MAX];
LL sum[MAX<<2];

void pushup(int rt){
sum[rt]=sum[lrt]+sum[rrt];
}

void build(int l,int r,int rt){
sum[rt]=0;
if(l==r) return;
middle;
build(lson);
build(rson);
pushup(rt);
}

void update(int l,int r,int rt,int pos,int d){
if(l==r){
sum[rt]=d;
return;
}
middle;
if(pos<=m) update(lson,pos,d);
else update(rson,pos,d);
pushup(rt);
}

LL query(int l,int r,int rt,int L,int R){
if(L<=l&&r<=R) return sum[rt];
middle;
LL ans=0;
if(L<=m) ans+=query(lson,L,R);
if(R>m) ans+=query(rson,L,R);
return ans;
}

int main(){
int t;
cin>>t;
while(t--){
int n;
cin>>n;
mem(pre,-1);
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
pos[a[i]]=-1;
}
for(int i=1;i<=n;i++){
if(pos[a[i]]!=-1){
pre[i]=pos[a[i]];
pos[a[i]]=i;
}
else pos[a[i]]=i;
}
build(1,n,1);
int m;
cin>>m;
for(int i=0;i<m;i++){
int l,r;
scanf("%d%d",&l,&r);
p[i]=(Node){l,r,i};
}
sort(p,p+m);
for(int i=1;i<=n;i++){
if(pre[i]!=-1) update(1,n,1,pre[i],0);
update(1,n,1,i,a[i]);
}
int r=n;
for(int i=0;i<m;i++){
while(r>p[i].r){
if(pre[r]!=-1) update(1,n,1,pre[r],a[r]);
r--;
}
ans[p[i].id]=query(1,n,1,p[i].l,p[i].r);
}
for(int i=0;i<m;i++){
printf("%I64d\n",ans[i]);
}
}
return 0;
}

hdu 4638
http://acm.hdu.edu.cn/showproblem.php?pid=4638

#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <cstdio>
#include <cctype>
#include <cstring>
#include <sstream>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#pragma comment(linker, "/STACK:102400000,102400000")

using namespace std;
#define   MAX           100005
#define   MAXN          6005
#define   maxnode       15
#define   sigma_size    30
#define   lson          l,m,rt<<1
#define   rson          m+1,r,rt<<1|1
#define   lrt           rt<<1
#define   rrt           rt<<1|1
#define   middle        int m=(r+l)>>1
#define   LL            long long
#define   ull           unsigned long long
#define   mem(x,v)      memset(x,v,sizeof(x))
#define   lowbit(x)     (x&-x)
#define   pii           pair<int,int>
#define   bits(a)       __builtin_popcount(a)
#define   mk            make_pair
#define   limit         10000

//const int    prime = 999983;
const int    INF   = 0x3f3f3f3f;
const LL     INFF  = 0x3f3f;
const double pi    = acos(-1.0);
//const double inf   = 1e18;
const double eps   = 1e-8;
const LL    mod    = 1e9+7;
const ull    mx    = 133333331;

/*****************************************************/
inline void RI(int &x) {
char c;
while((c=getchar())<'0' || c>'9');
x=c-'0';
while((c=getchar())>='0' && c<='9') x=(x<<3)+(x<<1)+c-'0';
}
/*****************************************************/

int pos[MAX];
int a[MAX];
struct que{
int l,r,id;
bool operator < (const que&e)const{
return r<e.r;
}
}p[MAX];
int ans[MAX];
int sum[MAX<<2];

void pushup(int rt){
sum[rt]=sum[lrt]+sum[rrt];
}
void build(int l,int r,int rt){
if(l==r){
sum[rt]=0;
return;
}
middle;
build(lson);
build(rson);
pushup(rt);
}

void update(int l,int r,int rt,int pos,int d){
if(l==r){
sum[rt]+=d;
return;
}
middle;
if(pos<=m) update(lson,pos,d);
else update(rson,pos,d);
pushup(rt);
}

int query(int l,int r,int rt,int L,int R){
if(L<=l&&r<=R) return sum[rt];
middle;
int ans=0;
if(L<=m) ans+=query(lson,L,R);
if(R>m) ans+=query(rson,L,R);
return ans;
}
int main(){
int t;
cin>>t;
while(t--){
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++){
scanf("%d",&a[i]);
pos[a[i]]=i;
}
for(int i=0;i<m;i++){
int l,r;
scanf("%d%d",&l,&r);
p[i]=(que){l,r,i};
}
sort(p,p+m);
build(1,n,1);
int tot=0;
for(int i=1;i<=n;i++){
update(1,n,1,i,1);
if(pos[a[i]-1]&&pos[a[i]-1]<=i) update(1,n,1,pos[a[i]-1],-1);
if(pos[a[i]+1]&&pos[a[i]+1]<=i) update(1,n,1,pos[a[i]+1],-1);
while(tot<m&&p[tot].r==i){
ans[p[tot].id]=query(1,n,1,p[tot].l,p[tot].r);
tot++;
}
}
for(int i=0;i<m;i++) printf("%d\n",ans[i]);
}
return 0;
}

#### 专题学习网站

2013年04月18日 10.56MB 下载

#### RabbitMQ （消息队列）专题学习02 Hello World

2014-05-05 22:03:21

#### DIV+CSS基础教程：浮动(float)页面布局

2013-03-12 22:23:56

#### RabbitMQ （消息队列）专题学习03 Work Queues(工作队列)

2014-05-05 23:28:14

#### 搜索引擎学习之一:网络爬虫

2006-11-08 15:14:00

#### 利用思维导图学习分布式数据库系统（一）

2013-10-25 08:46:11

#### C#正则表达式专题学习（很不错）附正则测试工具

2009年12月09日 351KB 下载

#### .Net学习心得

2014-06-12 21:11:09

#### 专题学习网站JSP

2015年04月15日 29.59MB 下载

#### MySQL 5.0存储过程

2010年10月25日 470KB 下载