Codeforces Round 888 (Div. 3) A题

One day, Vlad became curious about who he can have a conversation with on the escalator in the subway. There are a total of n passengers. The escalator has a total of m steps, all steps indexed from 11 to m and i-th step has height i⋅k

Vlad's height is H centimeters. Two people with heights a and b 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 170170 and 180180 centimeters, and m=10,k=5, then they can stand on steps numbered 77 and 55, where the height difference between the steps is equal to the height difference between the two people: k⋅2=5⋅2=10=180−170 There are other possible ways.

Given an array hℎ of size n, where hi represents the height of the i-th person. Vlad is interested in how many people he can have a conversation with on the escalator individually.

For example, if n=5,m=3,k=3,H=11, and h=[5,4,14,18,2] Vlad can have a conversation with the person with height 55 (Vlad will stand on step 11, and the other person will stand on step 33) and with the person with height 1414 (for example, Vlad can stand on step 33, and the other person will stand on step 22). Vlad cannot have a conversation with the person with height 22 because even if they stand on the extreme steps of the escalator, the height difference between them will be 66, while their height difference is 99. Vlad cannot have a conversation with the rest of the people on the escalator, so the answer for this example is 22.

Input

The first line contains a single integer t (1≤t≤1000) — the number of test cases.

Then the descriptions of the test cases follow.

The first line of each test case contains integers: n,m,k,H(1≤n,m≤50 1≤k,H≤10的六次方). Here, n is the number of people, m is the number of steps, k is the height difference between neighboring steps, and H is Vlad's height.

The second line contains n integers: h1,h2,…,hn (1≤hi≤10的六次方). Here, h represents the height of the i-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.

Example

input

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

output

2
1
4
1
0
0
3

题目链接  Problem - A - Codeforces

代码

#include<bits/stdc++.h>
using namespace std;
int maxn=1e5+50;
int a[505];
int main()
{
	int t;
	cin>>t;

	while(t--)
	{
		int n,m,k,h;
		cin>>n>>m>>k>>h;
		for(int x=1;x<=n;x++)
		{
			cin>>a[x];
		}
		int ans=0;
		for(int x=1;x<=n;x++)
			for(int y=1;y<m;y++)
				if(a[x]<h)
				{
					if(a[x]+k*y==h)
					{
						ans++;
					}
				}
				else if(a[x]>h)
				{
					if(a[x]-k*y==h)
					{
						ans++;
					}
				}
		cout<<ans<<endl;
	}
	return 0;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Codeforces Round 894 (Div. 3) 是一个Codeforces举办的比赛,是第894轮的Div. 3级别比赛。它包含了一系列目,其中包括目E. Kolya and Movie Theatre。 根据目描述,E. Kolya and Movie Theatre问要求我们给定两个字符串,通过三种操作来让字符串a等于字符串b。这三种操作分别为:交换a中相同位置的字符、交换a中对称位置的字符、交换b中对称位置的字符。我们需要先进行一次预处理,替换a中的字符,然后进行上述三种操作,最终得到a等于b的结果。我们需要计算预处理操作的次数。 根据引用的讨论,当且仅当b[i]==b[n-i-1]时,如果a[i]!=a[n-i-1],需要进行一次操作;否则不需要操作。所以我们可以遍历字符串b的前半部分,判断对应位置的字符是否与后半部分对称,并统计需要进行操作的次数。 以上就是Codeforces Round 894 (Div. 3)的简要说明和目E. Kolya and Movie Theatre的要求。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* [Codeforces Round #498 (Div. 3) (A+B+C+D+E+F)](https://blog.csdn.net/qq_46030630/article/details/108804114)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *3* [Codeforces Round 894 (Div. 3)A~E解](https://blog.csdn.net/gyeolhada/article/details/132491891)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值