Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Recurrent Function
Description Dr. Yao is involved in a secret research on the topic of the properties of recurrent function. Some of the functions in this research are in the following pattern: in which set { d-1} and {b} = {0, 1, …, _{i}d-1}.We denote: Yao's question is that, given two positive integer Input There are several test cases. The first line of each test case contains an integer d (2≤d≤100). The second line contains 2d-1 integers: a_{1}, …, a_{d}_{-1}, followed by b_{0}, ..., b_{d}_{-1}. The third line contains integer m (0<m≤10^{100}), and the forth line contains integer k (0<k≤10^{100}). The input file ends with integer -1.
Output For each test case if it exists such an integer x, output the minimal one. We guarantee the answer is less than 2 ^{63}. Otherwise output a word "NO".
Sample Input 2 1 1 0 4 7 2 1 0 1 100 200 -1 Sample Output 1 NO Hint For the first sample case, we can see that f(4)=7. And for the second one, the function is f(i)=i.
Source POJ Founder Monthly Contest – 2008.12.28, Yaojinyu |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator