Nimber Sequence
Time limit1sMemory limit256 MB
Given a recurrence over nimbers using nim sum and nim product, find the m-th term a_m for m up to 10^18.
- Level
Hard8 of 10
- Topics
- Matrix, Math, Divide and conquer
- Solved
- No attempts yet
Statement
Nimbers , , and are given.
For all , the following holds.
Find the value of .
Input
The first line contains two positive integers and (, ).
The second line contains non-negative integers ().
The third line contains five non-negative integers ().
The fourth line contains five non-negative integers ().
Output
Output a single integer, the value of .
Hint
Nimbers are non-negative integers associated with Nim games. This problem needs two operations.
- is the nim sum: .
- is the nim product: .
Here, is the smallest non-negative integer that is not in .