Lunar New Year and a Recursive Sequence
1106F2400· grandmaster3s256 MB⌨ stdin/stdout
Examples
Sample 1of 6
Input
32 3 54 16
Output
4
Sample 2of 6
Input
54 7 1 5 67 14187219
Output
6
Sample 3of 6
Input
82 3 5 6 1 7 9 1023333 1
Output
1
Sample 4of 6
Input
1288888 66666
Output
-1
Sample 5of 6
Input
3998244352 998244352 9982443524 2
Output
-1
Sample 6of 6
Input
10283 463 213 777 346 201 463 283 102 9992333333 6263423
Output
382480067
58%
1106F.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)