CF1670F.Jee, You See?

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 nn, ll, rr, and zz. Count the number of arrays aa of length nn containing non-negative integers such that:

  • l≤a1+a2+…+an≤rl\le a_1+a_2+\ldots+a_n\le r, and
  • a1⊕a2⊕…⊕an=za_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 109+710^9+7.

在 ICPC 竞赛训练过程中,队伍“Jee You See”偶然遇到了一个非常基础的计数问题。在多次提交得到“答案错误(Wrong answer)”判定后,他们最终决定放弃并关掉电脑。现在他们希望你能帮忙补题(up-solving)解决该问题。

给定四个整数 nn、ll、rr 和 zz。请计算满足以下条件的长度为 nn 的数组 aa(其元素均为非负整数)的个数:

  • l≤a1+a2+…+an≤rl\le a_1+a_2+\ldots+a_n\le r,且
  • a1⊕a2⊕…⊕an=za_1\oplus a_2 \oplus \ldots\oplus a_n=z,其中 ⊕\oplus 表示按位异或(bitwise XOR) 运算。

由于答案可能很大,请将结果对 109+710^9+7 取模后输出。

输入格式

The only line contains four integers nn, ll, rr, zz (1≤n≤10001 \le n \le 1000, 1≤l≤r≤10181\le l\le r\le 10^{18}, 1≤z≤10181\le z\le 10^{18}).

唯一一行包含四个整数 nn、ll、rr、zz(1≤n≤10001 \le n \le 1000,1≤l≤r≤10181\le l\le r\le 10^{18},1≤z≤10181\le z\le 10^{18})。

输出格式

Print the number of arrays aa satisfying all requirements modulo 109+710^9+7.

输出满足所有要求的数组 aa 的数量,对 109+710^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][1, 0, 0];
  • [0,1,0][0, 1, 0];
  • [3,2,0][3, 2, 0];
  • [2,3,0][2, 3, 0];
  • [0,0,1][0, 0, 1];
  • [1,1,1][1, 1, 1];
  • [2,2,1][2, 2, 1];
  • [3,0,2][3, 0, 2];
  • [2,1,2][2, 1, 2];
  • [1,2,2][1, 2, 2];
  • [0,3,2][0, 3, 2];
  • [2,0,3][2, 0, 3];
  • [0,2,3][0, 2, 3].

The following arrays satisfy the conditions for the second sample:

  • [2,0,0,0][2, 0, 0, 0];
  • [0,2,0,0][0, 2, 0, 0];
  • [0,0,2,0][0, 0, 2, 0];
  • [0,0,0,2][0, 0, 0, 2].

以下数组满足第一个样例的条件:

  • [1,0,0][1, 0, 0];
  • [0,1,0][0, 1, 0];
  • [3,2,0][3, 2, 0];
  • [2,3,0][2, 3, 0];
  • [0,0,1][0, 0, 1];
  • [1,1,1][1, 1, 1];
  • [2,2,1][2, 2, 1];
  • [3,0,2][3, 0, 2];
  • [2,1,2][2, 1, 2];
  • [1,2,2][1, 2, 2];
  • [0,3,2][0, 3, 2];
  • [2,0,3][2, 0, 3];
  • [0,2,3][0, 2, 3]。

以下数组满足第二个样例的条件:

  • [2,0,0,0][2, 0, 0, 0];
  • [0,2,0,0][0, 2, 0, 0];
  • [0,0,2,0][0, 0, 2, 0];
  • [0,0,0,2][0, 0, 0, 2]。

输入解题思路,AI测评打分。不知道怎么写?

首页