Periodic Function (Easy)
InterviewTime limit0.5sMemory limit1024 MB
Given the integral of a periodic function over each unit interval in one period, compute the integral over an arbitrary interval [a, b].
- Level
Easy3 of 10
- Topics
- Prefix sum, Math
- Solved
- No attempts yet
Statement
This problem has different input constraints from Periodic Function (Hard).
A periodic function is a function whose values repeat at regular intervals. Formally, if there is a positive number such that for all , then is called a periodic function, and is called a period. A single function can have several periods. For example, if , then is a period for every positive integer .
Periodic functions make definite integrals easier to compute, because shifting the interval by one period does not change the value. For example, the period of is , so .
Every day, Dooyoung brings Ian a periodic function that Ian has never seen. Dooyoung gives the integral over an interval whose length equals the period, and asks Ian to find the integral over another interval. Tired of solving these by hand, Ian wants a program that computes the answers automatically.
Input
The first line contains the period of the function.
The second line contains integers separated by spaces. For , the -th number is .
The third line contains two integers and separated by a space, the endpoints of the interval to find.
Output
Print the value of on one line.
Constraints
- The absolute value of every integral is at most .
- All input values are integers.