A. Army

Source: Internet
Author: User
Time limit per test

2 seconds

Memory limit per test

256 megabytes

Input

Standard Input

Output

Standard output

The berland Armed Forces system consistsNRanks that are numbered using natural numbers from 1N,
Where 1 is the lowest rank andNIs
The highest rank.

One needs exactlyDIYears
To rise from rankITo rankIUpload + upload 1.
Reaching a certain rankIHaving not reached all the previousIRandom-Sort 1 ranks
Is impossible.

Vasya has just reached a new rankA, But he dreams of holding the rankB.
Find for how many more years Vasya shocould serve in the army until he can finally realize his dream.

Input

The first input line contains an integerN(2 cores ≤ CoresNLimit ≤ limit 100 ).
The second line containsNAccept-rule 1 IntegersDI(1 digit ≤ DigitDILimit ≤ limit 100 ).
The third input line contains two integersAAndB(1 digit ≤ DigitALatency <latencyBLimit ≤ limitN).
The numbers on the lines are space-separated.

Output

Print the single number which is the number of years that Vasya needs to rise from rankATo rankB.

Sample test (s) Input
35 61 2
Output
5
Input
35 61 3
Output
11

Description: calculates the sum of numbers in a specified range.

#include<cstdio>#include<iostream>#include<cstring>#include<cmath>using namespace std;int main(){int n,i,a,b;int d[101];int sum;sum=0;scanf("%d",&n);for(i=0;i<n-1;i++){scanf("%d",&d[i]);}scanf("%d %d",&a,&b);for(i=a-1;i<b-1;i++){sum+=d[i];}printf("%d\n",sum);return 0;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.