标签:一段 php cstring title style other can mission tput
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 98106 Accepted Submission(s): 41505
1 #include <algorithm> 2 #include <cstring> 3 #include <cstdio> 4 5 using namespace std; 6 7 const int N(50000+5); 8 int n,tr[N],x,y; 9 10 #define lowbit(x) (x&((~x)+1)) 11 inline void Update(int i,int x) 12 { 13 for(;i<=N;i+=lowbit(i)) tr[i]+=x; 14 } 15 inline int Query(int x) 16 { 17 int ret=0; 18 for(;x;x-=lowbit(x)) ret+=tr[x]; 19 return ret; 20 } 21 22 int main() 23 { 24 int t; scanf("%d",&t); 25 for(int i=1;i<=t;i++) 26 { 27 memset(tr,0,sizeof(tr)); 28 printf("Case %d:\n",i); 29 scanf("%d",&n); 30 for(int i=1;i<=n;i++) 31 scanf("%d",&x),Update(i,x); 32 for(char ch[5];scanf("%s",ch);) 33 { 34 if(ch[0]==‘E‘) break; 35 scanf("%d%d",&x,&y); 36 if(ch[0]==‘A‘) Update(x,y); 37 else if(ch[0]==‘S‘) Update(x,-y); 38 else printf("%d\n",Query(y)-Query(x-1)); 39 } 40 } 41 return 0; 42 }
标签:一段 php cstring title style other can mission tput
原文地址:http://www.cnblogs.com/Shy-key/p/7393866.html