cf/mirror

Lunar New Year and a Recursive Sequence

CF
1106F2400· grandmaster3s256 MB⌨ stdin/stdout

Examples

Sample 1of 6
Input
3
2 3 5
4 16
Output
4
Sample 2of 6
Input
5
4 7 1 5 6
7 14187219
Output
6
Sample 3of 6
Input
8
2 3 5 6 1 7 9 10
23333 1
Output
1
Sample 4of 6
Input
1
2
88888 66666
Output
-1
Sample 5of 6
Input
3
998244352 998244352 998244352
4 2
Output
-1
Sample 6of 6
Input
10
283 463 213 777 346 201 463 283 102 999
2333333 6263423
Output
382480067
1106F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)