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;}