A10374 | Mike and Geometry Problem
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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])=r-l+1$ to be the number of integer points in the segment $[l,r]$ with $l<=r$ (say that ). You are given two integers $n$ and $k$ and $n$ closed intervals $[l_{i},r_{i}]$ on $OX$ 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 $k$ of the segments.
As the answer may be very large, output it modulo $1000000007$ ( $10^{9}+7$ ).
Mike can't solve this problem so he needs your help. You will help him, won't you?
In other words, you should find the sum of the number of integer points in the intersection of any $k$ of the segments.
As the answer may be very large, output it modulo $1000000007$ ( $10^{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 $n$ and $k$ ( $1<=k<=n<=200000$ ) — the number of segments and the number of segments in intersection groups respectively.
Then $n$ lines follow, the $i$ -th line contains two integers $l_{i},r_{i}$ $(-10^{9}<=l_{i}<=r_{i}<=10^{9})$ , describing $i$ -th segment bounds.
Then $n$ lines follow, the $i$ -th line contains two integers $l_{i},r_{i}$ $(-10^{9}<=l_{i}<=r_{i}<=10^{9})$ , describing $i$ -th segment bounds.
输出格式
Print one integer number — the answer to Mike's problem modulo $1000000007$ ( $10^{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=5$ .
;
;
.
So the answer is $2+1+2=5$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted