第十届山东理工大学ACM网络编程擂台赛 热身赛B

From axuhongbo, 3 Years ago, written in C++, viewed 402 times.
URL http://axuhongbo.top/paste/view/2405780e Embed
Download Paste or View Raw
  1. include <iostream>
  2. include <bits/stdc++.h>
  3. using namespace std;
  4. int a[1000000];
  5. int main()
  6. {
  7.     int n;
  8.     scanf("%d",&n);
  9.     a[0]=0;
  10.     for(int i=1; i<=n; i++)
  11.     {
  12.         scanf("%d",&a[i]);
  13.         if(i!=0)
  14.             a[i]+=a[i-1];
  15.     }
  16.     int l,r;
  17.     while(scanf("%d%d",&l,&r))
  18.     {
  19.         if(l==0&&r==0)
  20.             break;
  21.         printf("%d\n",a[r]-a[l-1]);
  22.     }
  23.     return 0;
  24. }
  25.  

Reply to "第十届山东理工大学ACM网络编程擂台赛 热身赛B"

Here you can reply to the paste above

captcha