Heim > Web-Frontend > HTML-Tutorial > Codeforces Round #274 (Div. 2) D. Long Jumps_html/css_WEB-ITnose

Codeforces Round #274 (Div. 2) D. Long Jumps_html/css_WEB-ITnose

WBOY
Freigeben: 2016-06-24 11:55:52
Original
1246 Leute haben es durchsucht

Valery is a PE teacher at a school in Berland. Soon the students are going to take a test in long jumps, and Valery has lost his favorite ruler!

However, there is no reason for disappointment, as Valery has found another ruler, its length is l centimeters. The ruler already has nmarks, with which he can make measurements. We assume that the marks are numbered from 1 to n in the order they appear from the beginning of the ruler to its end. The first point coincides with the beginning of the ruler and represents the origin. The last mark coincides with the end of the ruler, at distance l from the origin. This ruler can be repesented by an increasing sequence a1,?a2,?...,?an, where aidenotes the distance of the i-th mark from the origin (a1?=?0, an?=?l).

Valery believes that with a ruler he can measure the distance of d centimeters, if there is a pair of integers i and j (1?≤?i?≤?j?≤?n), such that the distance between the i-th and the j-th mark is exactly equal to d (in other words, aj?-?ai?=?d).

Under the rules, the girls should be able to jump at least x centimeters, and the boys should be able to jump at least y (x?

Your task is to determine what is the minimum number of additional marks you need to add on the ruler so that they can be used to measure the distances x and y. Valery can add the marks at any integer non-negative distance from the origin not exceeding the length of the ruler.

Input

The first line contains four positive space-separated integers n, l, x, y (2?≤?n?≤?105, 2?≤?l?≤?109, 1?≤?x?

The second line contains a sequence of n integers a1,?a2,?...,?an (0?=?a1?

Output

In the first line print a single non-negative integer v ? the minimum number of marks that you need to add on the ruler.

In the second line print v space-separated integers p1,?p2,?...,?pv (0?≤?pi?≤?l). Number pi means that the i-th mark should be at the distance of pi centimeters from the origin. Print the marks in any order. If there are multiple solutions, print any of them.

Sample test(s)

input

3 250 185 2300 185 250
Nach dem Login kopieren

output

1230
Nach dem Login kopieren

input

4 250 185 2300 20 185 250
Nach dem Login kopieren

output

input

2 300 185 2300 300
Nach dem Login kopieren

output

2185 230
Nach dem Login kopieren
题意:给你n个刻度,让你量长度为x和y的距离,求还要增加几个刻度

思路:显然答案最多就是2了,我们先判断现有的刻度有没有可以量出的,然后就是找了,看看能不能加一个量出两个,不然就加两个刻度

#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <set>using namespace std;const int maxn = 100005;set<int> s;int n, a[maxn], x, y, l;int find() {	for (int i = 1; i = 0 && (s.count(a[i]-x+y) || s.count(a[i]-x-y)))			return a[i] - x;	}	return -1;}int check(int m) {	for (int i = 1; i   <br>  <br>  <p></p>  <p><br> </p>  <p><br> </p> </int></set></algorithm></cstring></cstdio></iostream>
Nach dem Login kopieren
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage