欢迎来到起遇信息学
起遇信息学正处于上线筹建阶段,以下功能已全部开放免费体验: ✅ 完整题库浏览与代码提交评测(C / C++ / Python / Java 等) ✅ 入门到进阶的系列课程试读、作业与考试 ✅ AI 提示、AI 作业分析等智能助教功能 ✅ 赛事模拟与个人能力报告 ✅ 邮箱注册开放 ⏳ 付费课程订阅与微信/支付宝支付通道 ⏳ 手机号登录,微信扫码登录、微信公众号绑定 使用中如遇任何问题,欢迎通过页面底部 **"联系我们"** 与我们沟通。
CF1851A.Escalator Conversations
Escalator Conversations
One day, Vlad became curious about who he can have a conversation with on the escalator in the subway. There are a total of passengers. The escalator has a total of steps, all steps indexed from to and -th step has height .
Vlad's height is centimeters. Two people with heights and can have a conversation on the escalator if they are standing on different steps and the height difference between them is equal to the height difference between the steps.
For example, if two people have heights and centimeters, and , then they can stand on steps numbered and , where the height difference between the steps is equal to the height difference between the two people: . There are other possible ways.
Given an array of size , where represents the height of the -th person. Vlad is interested in how many people he can have a conversation with on the escalator individually.
For example, if , and , Vlad can have a conversation with the person with height (Vlad will stand on step , and the other person will stand on step ) and with the person with height (for example, Vlad can stand on step , and the other person will stand on step ). Vlad cannot have a conversation with the person with height because even if they stand on the extreme steps of the escalator, the height difference between them will be , while their height difference is . Vlad cannot have a conversation with the rest of the people on the escalator, so the answer for this example is .
Input
The first line contains a single integer () — the number of test cases.
Then the descriptions of the test cases follow.
The first line of each test case contains integers: (, ). Here, is the number of people, is the number of steps, is the height difference between neighboring steps, and is Vlad's height.
The second line contains integers: (). Here, represents the height of the -th person.
Output
For each test case, output a single integer — the number of people Vlad can have a conversation with on the escalator individually.
Note
The first example is explained in the problem statement.
In the second example, Vlad can have a conversation with the person with height .
In the third example, Vlad can have a conversation with people with heights: . Therefore, the answer is .
In the fourth example, Vlad can have a conversation with the person with height .
Samples
7
5 3 3 11
5 4 14 18 2
2 9 5 6
11 9
10 50 3 11
43 44 74 98 62 60 99 4 11 73
4 8 8 49
68 58 82 73
7 1 4 66
18 66 39 83 48 99 79
9 1 1 13
26 23 84 6 60 87 40 41 25
6 13 3 28
30 70 85 13 1 55
2
1
4
1
0
0
3
在线编程 IDE
建议全屏模式获得最佳体验
| 进入全屏编程 | Alt+E |
| 递交评测 | Ctrl+Enter |
| 注释/取消注释 | Ctrl+/ |
| 缩放字体 | Ctrl+滚轮 |