Infinite Sequence - 2
Very easy
Execution time limit is 2 seconds
Runtime memory usage limit is 128 megabytes
Consider an infinite sequence defined as follows:
,
You will be given and . Find the -th element of (index is -based).
Input
Five integers .
Output
Print the value of .
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 4K
Acceptance rate 26%