|
|
back to boardwhy WA10? someone please help? here is my C code #include<stdio.h> #include<stdlib.h> int main(void) { int n,x,i,l,m; long *a=0,*b=0; scanf("%d",&n); a=(long*)malloc((n+1)*n); a[0]=0; for(i=1;i<n+1;++i) { scanf("%d",&x); a[i]=a[i-1]+ x; } scanf("%d",&x); b=(long*)malloc(x*sizeof(long)); for(i=0;i<x;++i) { scanf("%d %d",&l,&m); b[i]=a[m]-a[l-1]; } for(i=0;i<x-1;++i) printf("%ld\n",b[i]); printf("%ld",b[i]); return 0; } |
|
|