A796.Cowmistry--Platinum
NOI/NOI+/CTSC
通过率:0%
时间限制:1.00s
内存限制:128MB
题目描述
Bessie has been procrastinating on her cow-mistry homework and needs your help. She wants to create a mixture containing three different cow-michals. Two cow-michals with labels a and b can be in the same mixture only if a⊕b≤K.
Here, a⊕b is the bitwise exclusive OR of the two non-negative integers. It is computed by adding each pair of corresponding binary digits without carrying. For example:
0⊕0=1⊕1=0,
1⊕0=0⊕1=1,
5⊕7=1012⊕1112=0102=2.
Bessie has N boxes. The i-th box contains cow-michals labeled from li through ri, inclusive. No two boxes contain any cow-michals in common.
Count the number of different mixtures of three distinct cow-michals that Bessie can create. Two mixtures are different if they contain different sets of cow-michals. Output the answer modulo 109+7.
输入格式
The first line contains two integers N and K.
Each of the next N lines contains two integers li and ri, describing the labels in one box. The boxes are given in increasing order and do not overlap: ri<li+1 for 1≤i<N.
输出格式
Output the number of different mixtures of three distinct cow-michals, modulo 109+7.
输入输出样例
输入#1
1 13 0 199
输出#1
4280
输入#2
6 147 1 35 48 103 125 127 154 190 195 235 240 250
输出#2
267188
说明/提示
数据范围:
| 测试点 | 数据范围 |
|---|---|
| 03–04 | max(K,rN)≤104 |
| 07–11 | max(K,rN)≤106 |
| 12–16 | N≤20 |
| 17–21 | 无额外限制 |
测试点 01–02 为题面样例。原题另注明测试点 05–06 满足 K=2k−1,其中 k≥1。
输入解题思路,AI测评打分。不知道怎么写?