CF689E.Mike and Geometry Problem

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

Mike wants to prepare for IMO but he doesn't know geometry, so his teacher gave him an interesting geometry problem. Let's define f([l,r])=rl+1f([l,r])=r-l+1 to be the number of integer points in the segment [l,r][l,r] with l<=rl<=r (say that ). You are given two integers nn and kk and nn closed intervals [li,ri][l_{i},r_{i}] on OXOX axis and you have to find:

In other words, you should find the sum of the number of integer points in the intersection of any kk of the segments.

As the answer may be very large, output it modulo 10000000071000000007 ( 109+710^{9}+7 ).

Mike can't solve this problem so he needs your help. You will help him, won't you?

输入格式

The first line contains two integers nn and kk ( 1<=k<=n<=2000001<=k<=n<=200000 ) — the number of segments and the number of segments in intersection groups respectively.

Then nn lines follow, the ii -th line contains two integers li,ril_{i},r_{i} (109<=li<=ri<=109)(-10^{9}<=l_{i}<=r_{i}<=10^{9}) , describing ii -th segment bounds.

输出格式

Print one integer number — the answer to Mike's problem modulo 10000000071000000007 ( 109+710^{9}+7 ) in the only line.

输入输出样例

  • 输入#1

    3 2
    1 2
    1 3
    2 3
    

    输出#1

    5
    
  • 输入#2

    3 3
    1 3
    1 3
    1 3
    

    输出#2

    3
    
  • 输入#3

    3 1
    1 2
    2 3
    3 4
    

    输出#3

    6
    

说明/提示

In the first example:

;

;

.

So the answer is 2+1+2=52+1+2=5 .

首页