| TheForces Round #21 (EDU-Forces) |
|---|
| Закончено |
While AHF loves short descriptions, he has noticed that the descriptions for earlier problems have been longer than he wanted. Therefore, he decided to keep this problem's description as short as possible.
Let us declare function $$$f(x)$$$ for a positive number $$$x$$$ as the number of adjacent indices $$$i$$$ $$$(0 \le i \lt \lfloor{\log _2 x }\rfloor)$$$ in $$$B$$$, defined as the binary representation of $$$x$$$, meeting the condition $$$B_i \neq B_{i+1}$$$, for example, $$$f(5) = f({101}_2) = 2$$$.
You're given positive integers $$$k$$$ and $$$n$$$, calculate how many numbers $$$x$$$ exist, such that $$$1 \le x \le n$$$ and $$$f(x) = k$$$, As AHF considers this easy for only one query, He wants you to answer $$$q$$$ independent queries.
On the first line of the input, you will receive a positive integer $$$q$$$ ($$$1 \le q \le 10^5$$$), which is the number of queries. On the $$$q$$$ following lines, you will receive two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le 60$$$, $$$1 \le n \le 2^{60} - 1$$$) in corresponding order.
For each query, output the answer in one line.
106 21 6094 332 598 3123 22012 53443 2454543 123232123 10
1 0 25 0 26 34 461 0 499 536402
| Название |
|---|


