0

0

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

php中文网

php中文网

发布时间:2016-06-24 11:55:52

|

1419人浏览过

|

来源于php中文网

原创

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.

PaperFake
PaperFake

AI写论文

下载

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

output

1230

input

4 250 185 2300 20 185 250

output

input

2 300 185 2300 300

output

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

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

#include #include #include #include #include using namespace std;const int maxn = 100005;set s;int n, a[maxn], x, y, l;int find() {	for (int i = 1; i <= n; i++) {		if (a[i]+x <= l && (s.count(a[i]+x+y) || s.count(a[i]+x-y)))			return a[i] + x;		if (a[i]-x >= 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 <= n; i++)		if (s.count(a[i]-m))			return 1;	return 0;}int main() {	scanf("%d%d%d%d", &n, &l, &x, &y);	for (int i = 1; i <= n; i++) {		scanf("%d", &a[i]);		s.insert(a[i]);	}	int t1 = check(x), t2 = check(y);	if (t1 && t2) 		printf("0\n");	else if (t1 && !t2)		printf("1\n%d\n", y);	else if (!t1 && t2)		printf("1\n%d\n", x);	else {		int flag = find();		if (flag == -1)			printf("2\n%d %d\n", x, y);		else printf("1\n%d\n", flag);	}	return 0;}




HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载

本站声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热门AI工具

更多
DeepSeek
DeepSeek

幻方量化公司旗下的开源大模型平台

豆包大模型
豆包大模型

字节跳动自主研发的一系列大型语言模型

通义千问
通义千问

阿里巴巴推出的全能AI助手

腾讯元宝
腾讯元宝

腾讯混元平台推出的AI助手

文心一言
文心一言

文心一言是百度开发的AI聊天机器人,通过对话可以生成各种形式的内容。

讯飞写作
讯飞写作

基于讯飞星火大模型的AI写作工具,可以快速生成新闻稿件、品宣文案、工作总结、心得体会等各种文文稿

即梦AI
即梦AI

一站式AI创作平台,免费AI图片和视频生成。

ChatGPT
ChatGPT

最最强大的AI聊天机器人程序,ChatGPT不单是聊天机器人,还能进行撰写邮件、视频脚本、文案、翻译、代码等任务。

相关专题

更多
java连接字符串方法汇总
java连接字符串方法汇总

本专题整合了java连接字符串教程合集,阅读专题下面的文章了解更多详细操作。

7

2026.02.05

java中fail含义
java中fail含义

本专题整合了java中fail的含义、作用相关内容,阅读专题下面的文章了解更多详细内容。

8

2026.02.05

控制反转和依赖注入区别
控制反转和依赖注入区别

本专题整合了控制反转和依赖注入区别、解释、实现方法相关内容。阅读专题下面的文章了解更多详细教程。

11

2026.02.05

钉钉脑图插图教程合集
钉钉脑图插图教程合集

本专题整合了钉钉脑图怎么插入图片、钉钉脑图怎么用相关教程,阅读专题下面的文章了解更多详细内容。

24

2026.02.05

python截取字符串方法汇总
python截取字符串方法汇总

本专题整合了python截取字符串方法相关合集,阅读专题下面的文章了解更多详细内容。

2

2026.02.05

Java截取字符串方法合集
Java截取字符串方法合集

本专题整合了Java截取字符串方法汇总,阅读专题下面的文章了解更多详细操作教程。

1

2026.02.05

java 抽象方法
java 抽象方法

本专题整合了java抽象方法定义、作用教程等内容,阅读专题下面的文章了解更多详细内容。

2

2026.02.05

Eclipse创建jsp文件教程合集
Eclipse创建jsp文件教程合集

本专题整合了Eclipse创建jsp文件、创建jsp项目等等内容,阅读专题下面的文章了解更多详细教程。

26

2026.02.05

java 字符串转数字
java 字符串转数字

本专题整合了java如何字符串转数字相关内容,阅读专题下面的文章了解更多详细教程。

4

2026.02.05

热门下载

更多
网站特效
/
网站源码
/
网站素材
/
前端模板

精品课程

更多
相关推荐
/
热门推荐
/
最新课程
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送

Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号