A796.Cowmistry--Platinum

NOI/NOI+/CTSC

USACO

通过率: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 aa and bb can be in the same mixture only if a⊕b≤Ka \oplus b \le K.

Here, a⊕ba\oplus 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,0\oplus 0=1\oplus 1=0,

1⊕0=0⊕1=1,1\oplus 0=0\oplus 1=1,

5⊕7=1012⊕1112=0102=2.5\oplus 7=101_2\oplus 111_2=010_2=2.

Bessie has NN boxes. The ii-th box contains cow-michals labeled from lil_i through rir_i, 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+710^9+7.

输入格式

The first line contains two integers NN and KK.

Each of the next NN lines contains two integers lil_i and rir_i, describing the labels in one box. The boxes are given in increasing order and do not overlap: ri<li+1r_i<l_{i+1} for 1≤i<N1\le i<N.

输出格式

Output the number of different mixtures of three distinct cow-michals, modulo 109+710^9+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\max(K,r_N)\le 10^4
07–11 max⁡(K,rN)≤106\max(K,r_N)\le 10^6
12–16 N≤20N\le 20
17–21 无额外限制

测试点 01–02 为题面样例。原题另注明测试点 05–06 满足 K=2k−1K=2^k-1,其中 k≥1k\ge1。

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

首页