B - Neo-Venice_sdau20163940的博客-程序员宅基地

技术标签: 2017年省赛赛前训练赛  

Mars was the first planet colonized by humans. After a long terraforming process its appearance has changed completely. From the red desert it has become a blue planet covered by water. There was so much water that some of the cities were built not on land, but on stilts over the water. The most famous one was Neo-Venice. There are canals instead of roads and numerous gondolas instead of cars in this city. All this attracts huge crowds of tourists from the Earth to Neo-Venice. The most popular activities among them are boat excursions. Gondolas are steered by young girls who can not only bring tourists through the canals but also tell them about the history of the city or sing a song along the way. Due to their love for the water these girls are called undines.
The undine Anna has just received a license to steer a gondola. Tomorrow she will carry tourists on excursion to the St. Peter's canal. This canal is narrow, but many popular routes are passing through it, so there are always a lot of gondolas. Anna is afraid that her excitement may lead to a crash with another gondola during the excursion. However, all undines are trained to steer the gondola smoothly and with the same speed, so the only threat comes from gondolas sailing in the opposite direction. Anna knows the schedule of her colleagues and when she herself will enter the canal. Now she wants to know exactly when she will encounter other gondolas, in order to be extra careful around them.
Input
The first line of the input contains integers  nt and  sn is the number of undines who will go through the St. Peter’s canal in the opposite direction (1 ≤  n ≤ 100).  t is the time needed for the gondola to sail through the entire length of the canal (1 ≤  t ≤ 100).  s is the moment of time at which the Anna's gondola will enter the canal (360 ≤  s ≤ 1200). The second line contains integers  s  1, …,  s  nthat define the moments of time at which the gondolas of Anna’s colleagues will appear on the opposite side of the canal.  s −  t <  s  1 < … <  s  n <  s +  t.
Output
Output  n numbers that are the points of time when Anna will meet her colleagues, with absolute or relative error no more than 10  −6. Numbers should be separated with spaces or line feeds.
Example
input output
2 60 600
600 630
630.000000
645.000000
Hint


解析:计算与N条逆向船只相遇的时间。直接计算。只要找到数学公式即可!!

代码:

#include<bits/stdc++.h>
using namespace std;
int main()
{
	double n,t,s,i,a;
	double t1,t2,tim;
	cin>>n>>t>>s;
	for(i=0;i<n;i++)
	{
		cin>>a;
		t1=a>s?a:s;
		t2=a<s?a:s;
		tim=t1+(t-t1+t2)/2;
		cout<<fixed<<setprecision(6)<<tim<<endl; 
	}
	return 0;
}
心得:

水水水!好伤心,今天唯一AC的一道题!!!

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/sinat_37668729/article/details/70940273

智能推荐

linux查看pci设备枚举,PCI 设备枚举流程_weixin_39559469的博客-程序员宅基地

//0、pci子系统首先注册pcibusstructbus_typepci_bus_type={.name ="pci",.match =pci_bus_match,.uevent =pci_uevent,.probe =pci_device_probe,.remove =pci_device_remove,...

Android Studio的报错提示::app:compileDebugJavaWithJavac_彬sir哥的博客-程序员宅基地

android studio的报错提示::app:compileDebugJavaWithJavacVideoAdapter.java错误: 不兼容的类型: void无法转换为booleanvoid无法转换为boolean:这代码下边的红色波浪线的原因可能是代码调用不了可能是刚添加的依赖包有问题:implementation 'fm.jiecao:jiecaovideoplayer:5.5.2'这依赖包的5.5.2,试试改版本高低肯定没问题,在网上找就即可找到新依赖包了:impl

[转贴]提问的智慧_weixin_30342209的博客-程序员宅基地

[转贴]提问的智慧:http://phorum.vbird.org/viewtopic.php?t=96%E3%80%8F%E8%BF%99%E4%B8%80%E7%AF%87%E8%AE%A8%E8%AE%BA%EF%BC%81%E7%84%B6%E5%90%8ECopyright (C) 2001 by Eric S. Raymond中文版Copyleft 2001 by D...

JFreeChart常用图表使用_纯洁的小新的博客-程序员宅基地_jfreechart

一、饼图 // 数据 DefaultPieDataset dataSet = new DefaultPieDataset(); dataSet.setValue("2020年", 26542);// 图例-值 dataSet.setValue("2021年", 27542);// 图例-值 dataSet.setValue("2022年", 28542);// 图例-值 StandardChartTheme standard

MariaDB Galera Cluster环境搭建及高可用测试_weixin_34314962的博客-程序员宅基地

一、服务器概况Galera Cluster需要至少三个节点,在此次实验过程中,三个节点IP地址:192.168.56.101192.168.56.102192.168.56.103OS为centos 7.2服务器配置:4G 内存,2核CPU,20G数据磁盘空间。关闭防火墙:service iptables stopsystemctl stop firewalldchkconfi...

03-移动端开发教程-CSS3新特性(下)_weixin_34363171的博客-程序员宅基地

1. CSS3动画1.1 过渡的缺点transition的优点在于简单易用,但是它有几个很大的局限。transition需要事件触发,所以没法在网页加载时自动发生。transition是一次性的,不能重复发生,除非一再触发。transition只能定义开始状态和结束状态,不能定义中间状态,也就是说只有一个开始状态和结束状态。一条transition规则,只能定义一个属性...

随便推点

【渝粤题库】广东开放大学 建筑CAD 形成性考核_渝粤题库的博客-程序员宅基地

选择题题目:&nbsp;AutoCAD中保存文件的格式包括以下几种。题目:AutoCAD中创建新文件时,在【选择样板】对话框中文件的类型包括_______?题目:AutoCAD的图形文件和样板文件的后缀名分别是_______。题目:&nbsp;AutoCAD中能够保存三维几何图形、视图、光源和材质的文件格式是?题目:AutoCAD的状态行中的锁定标识下的全部的意义为题目:栅格样式设置中,系统设置不在以下的位置显示点栅格?题目:AutoCAD 默认的单位是 ( )题目:&nbsp;AutoCA

【2019-2020春学期】数据库作业9:SQL练习6 - INSERT / UPDATE / DELETE / NULL / VIEW_Yt丶风行的博客-程序员宅基地

例3.69将一个新学生元组(学号:201215128,姓名:陈冬,性别:男,所在系:IS,年龄:18岁)插入到Student表中。INSERTINTO Student(Sno,Sname,Ssex,Sdept,Sage)VALUES(‘201215128’,‘陈冬’,‘男’,‘IS’,18);无异常例3.70将学生张成民的信息插入到Student表中。INSERTINTO Stu...

selenium编写脚本_用Selenium编写脚本_cuxiong8996的博客-程序员宅基地

IBM网站监控是用于网站探测和警报的综合解决方案。 此软件即服务(SaaS)产品包括: 第三方Mozilla Firefox附加组件:用于脚本编写的Selenium 应用程序性能管理以存储和运行探针 IBM Alert Notification(SaaS)用作警报系统 本系列从头到尾说明了如何使用IBM网站监控,包括脚本,设置警报以及配置技巧。 在这一部分中,您将学习如何...

chrome vim插件vimnum快捷键与使用_会思考的猴子的博客-程序员宅基地_vimnum

Navigating the pagej : Scroll down (scrollDown)k : Scroll up (scrollUp)h : Scroll left (scrollLeft)l : Scroll right (scrollRight)gg : Scroll to the top of the page (...

集群监控-Zabbix_弈·不晓的博客-程序员宅基地_集群监控

集群监控:zabbix、cacti(流量与性能监测为主 状态监测较差)、Nagios(服务与性能监测为主 监控监测好 展示差 收集方式 C/S (脚本 预定义))等,zabbix较为主流集合后两者优点,且开源。zabbix由zabbix-server zabbix-agent 构成zabbix定义:是一个基于web界面的提供分布式系统监视以及网络监视功能的企业级开源解决方案zabbix服务环境:LAMP,防火墙关闭,服务端需要有网配置环境[[email protected] ~]# ifconfig .