#STSC1A. [STSC OI - 1A] 加和 (sum)
[STSC OI - 1A] 加和 (sum)
Background
This problem is an exercise on prefix sums. Please solve this problem using prefix sums.
Please use C++, and use scanf() instead of std::cin.
Description
Given an integer sequence, find the sum from the -th term to the -th term.
Input
The input consists of lines:
- Line 1: A positive integer , the length of the integer sequence.
- Line 2: integers , representing the integer sequence.
- Line 3: Two positive integers and , indicating that we require the sum from the -th to the -th term.
Output
Output one line with a single integer , the sum from the -th to the -th term in the integer sequence.
6
178 24 16 -19 52 1
2 4
21
Hint
For test cases #1 to #10, it is guaranteed that , , and .
For test case #11, and .