A15009 | Jee, You See?
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation.
Since the answer can be large, print it modulo $10^9+7$ .
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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation.
Since the answer can be large, print it modulo $10^9+7$ .
输入格式
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}$ ).
输出格式
Print the number of arrays $a$ satisfying all requirements modulo $10^9+7$ .
输入输出样例
输入 #1
3 1 5 1
输出 #1
13
输入 #2
4 1 3 2
输出 #2
4
输入 #3
2 1 100000 15629
输出 #3
49152
输入 #4
100 56 89 66
输出 #4
981727503
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]$ .
- $[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]$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted