The problem is at first the wrong question. No idea at all.
To later the topic to see the right after, there is a little thought, but still do not do. Only to see the official
The official puzzle is this:
First convert numberkinto binary number system. If some bit ofkIs0 than the result oforOpertion applied for every adjacent pair of those bits in arrayaMust be0, that is no, and adjacent those bits in arrayaIs1. We should count how many times this is fulfilled. If The values were smaller we could count it with simplyDPI=DPI-1 +DPI-2, whereDPI is equal to number of ways to make array od i bits where no both is adjacent ones. With first values dp 1 = 2 and dp 2 = 3, we can see the" This is ordinary Fibonacci number. We can calculate Fibonacci numbers up to 1018 easily by Fast matrix Multip Lication. If some bit at K are 1 than number of ways is 2 n -\t{(number of ways bit is 0)}, which are also easy to calculate. We must be cearful for cases when 2 l smaller than K (solution is 0 then) and when l = or l = 64. Total complexity is.
After seeing it, I probably understood his idea. Consider each bits as a step, according to the multiplication principle, the total scheme number = The product of the number of schemes per bit.
If a binary value of K is zero, it is found that each adjacent element cannot be 1. Then DP, which is the Fibonacci sequence, matrix multiplication O (log n) No pressure
If one of the k's binary values is 1, then there must be a value of two adjacent elements of 1, and then found f[n]=2^ (n-1) +f[n-1] answer is 2*f[n-1], but this is very uncomfortable. Considering that this is a count class problem, from the negative side, the scheme is 2^n-dp[n] (Dp[n] refers to the value of a bits when it is zero), and then cool.
Codeforces #307 (Div. 2) Problem D. Gukiz and Binary Operations