A11400 | XK Segments
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
While Vasya finished eating his piece of pizza, the lesson has already started. For being late for the lesson, the teacher suggested Vasya to solve one interesting problem. Vasya has an array $a$ and integer $x$ . He should find the number of different ordered pairs of indexes $(i,j)$ such that $a_{i}<=a_{j}$ and there are exactly $k$ integers $y$ such that $a_{i}<=y<=a_{j}$ and $y$ is divisible by $x$ .
In this problem it is meant that pair $(i,j)$ is equal to $(j,i)$ only if $i$ is equal to $j$ . For example pair $(1,2)$ is not the same as $(2,1)$ .
In this problem it is meant that pair $(i,j)$ is equal to $(j,i)$ only if $i$ is equal to $j$ . For example pair $(1,2)$ is not the same as $(2,1)$ .
输入格式
The first line contains 3 integers $n,x,k$ ( $1<=n<=10^{5},1<=x<=10^{9},0<=k<=10^{9}$ ), where $n$ is the size of the array $a$ and $x$ and $k$ are numbers from the statement.
The second line contains $n$ integers $a_{i}$ ( $1<=a_{i}<=10^{9}$ ) — the elements of the array $a$ .
The second line contains $n$ integers $a_{i}$ ( $1<=a_{i}<=10^{9}$ ) — the elements of the array $a$ .
输出格式
Print one integer — the answer to the problem.
输入输出样例
输入 #1
4 2 1 1 3 5 7
输出 #1
3
输入 #2
4 2 0 5 3 1 7
输出 #2
4
输入 #3
5 3 1 3 3 3 3 3
输出 #3
25
In first sample there are only three suitable pairs of indexes — $(1,2),(2,3),(3,4)$ .
In second sample there are four suitable pairs of indexes $(1,1),(2,2),(3,3),(4,4)$ .
In third sample every pair $(i,j)$ is suitable, so the answer is $5*5=25$ .
In second sample there are four suitable pairs of indexes $(1,1),(2,2),(3,3),(4,4)$ .
In third sample every pair $(i,j)$ is suitable, so the answer is $5*5=25$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted