Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
递归比循环要快吗???TLE。。。Source Code #include<stdio.h> int main() { __int64 i,str,a,b,tests,n,k; __int64 add[100001]; char c[2]; scanf("%I64d%I64d",&n,&tests); add[0]=0; for(i=1;i<=n;i++) { scanf("%I64d",&str); add[i]=add[i-1]+str; } while(tests--) { scanf("%s",c); if(c[0]=='Q') { scanf("%I64d%I64d",&a,&b); printf("%I64d\n",add[b]-add[a-1]); } else { scanf("%I64d%I64d%I64d",&a,&b,&k); for(i=a;i<=b;i++) add[i]+=k*(i-a+1); k=k*(b-a+1); for(;i<=n;i++) add[i]+=k; } } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator