Codeforces Round 788 (Div. 2)
F
Jee, You See?
Codeforces
2400
原题
← E→
翻译中…

During their training for the ICPC competitions, team "Jee You See" stumbled upon a very basic counting problem. After many "Wrong answer" verdicts, they finally decided to give up and destroy turn-off the PC. Now they want your help in up-solving the problem.

翻译中…

You are given 4 integers $n$, $l$, $r$, and $z$. Count the number of arrays $a$ of length $n$ containing non-negative integers such that:

翻译中…
  • $l\le a_1+a_2+\ldots+a_n\le r$, and
  • $a_1\oplus a_2 \oplus \ldots\oplus a_n=z$, where $\oplus$ denotes the bitwise XOR operation.
翻译中…

Since the answer can be large, print it modulo $10^9+7$.

翻译中…

Input

翻译中…

The only line contains four integers $n$, $l$, $r$, $z$ ($1 \le n \le 1000$, $1\le l\le r\le 10^{18}$, $1\le z\le 10^{18}$).

翻译中…

Output

翻译中…

Print the number of arrays $a$ satisfying all requirements modulo $10^9+7$.

翻译中…

Note

翻译中…

The following arrays satisfy the conditions for the first sample:

翻译中…
  • $[1, 0, 0]$;
  • $[0, 1, 0]$;
  • $[3, 2, 0]$;
  • $[2, 3, 0]$;
  • $[0, 0, 1]$;
  • $[1, 1, 1]$;
  • $[2, 2, 1]$;
  • $[3, 0, 2]$;
  • $[2, 1, 2]$;
  • $[1, 2, 2]$;
  • $[0, 3, 2]$;
  • $[2, 0, 3]$;
  • $[0, 2, 3]$.
翻译中…

The following arrays satisfy the conditions for the second sample:

翻译中…
  • $[2, 0, 0, 0]$;
  • $[0, 2, 0, 0]$;
  • $[0, 0, 2, 0]$;
  • $[0, 0, 0, 2]$.
翻译中…

样例

Input #1
3 1 5 1
Output #1
13
InputCopy OutputCopy
Input #2
4 1 3 2
Output #2
4
InputCopy OutputCopy
Input #3
2 1 100000 15629
Output #3
49152
InputCopy OutputCopy
Input #4
100 56 89 66
Output #4
981727503
InputCopy OutputCopy
题目信息
题号
1670F
时间限制
2 s
内存限制
256 MB
标签
位运算
组合数学
动态规划

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。