#t91. 数列的第 m 个数
数列的第 m 个数
The m-th Term of the Sequence
Problem Description
There is an infinite sequence. Starting from the -th term, every terms form one cycle.
Specifically, the terms from the -th to the -th are the given integers in order, after which these numbers keep repeating.
Given , , these integers, and an integer , find the -th term of the sequence. It is guaranteed that .
Input Format
The first line contains two integers , satisfying .
The second line contains integers, representing the -th, -th, ..., -th terms of the sequence in order.
The third line contains an integer , satisfying .
Output Format
Output one integer, the value of the -th term of the sequence.
Sample Input
5 7
23 7 19 51 6
13
Sample Output
7
Sample Explanation
The given numbers start repeating from the 7th term, so the sequence from the 7th term is:
- 7th term = 23
- 8th term = 7
- 9th term = 19
- 10th term = 51
- 11th term = 6
- 12th term = 23
- 13th term = 7
So the 13th term is 7, and the output is 7.