博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
华中农业大学校赛 I Catching Dogs
阅读量:6312 次
发布时间:2019-06-22

本文共 1812 字,大约阅读时间需要 6 分钟。

Catching Dogs

Time Limit: 1 Sec  Memory Limit: 128 MB
Submit: 1140  Solved: 298
[][][]

Description

 

   Diao Yang keeps many dogs. But today his dogs all run away. Diao Yang has to catch them. To simplify the problem, we assume Diao Yang and all the dogs are on a number axis. The dogs are numbered from 1 to n. At first Diao Yang is on the original point and his speed is v. The ith dog is on the point ai and its speed is vi . Diao Yang will catch the dog by the order of their numbers. Which means only if Diao Yang has caught the ith dog, he can start to catch the (i+1)th dog, and immediately. Note that When Diao Yang catching a dog, he will run toward the dog and he will never stop or change his direction until he has caught the dog. Now Diao Yang wants to know how long it takes for him to catch all the dogs.

Input

 

    There are multiple test cases. In each test case, the first line contains two positive integers n(n≤10) andv(1≤v≤10). Then n lines followed, each line contains two integers ai(|ai|≤50) and vi(|vi|≤5). vi<0 means the dog runs toward left and vi>0 means the dog runs toward right. The input will end by EOF.

Output

    For each test case, output the answer. The answer should be rounded to 2 digits after decimal point. If Diao Yang cannot catch all the dogs, output “Bad Dog”(without quotes).

Sample Input

2 5-2 -32 31 62 -21 10 -11 1-1 -1

Sample Output

6.000.250.00Bad Dog

HINT

 

 

#include
#include
#include
using namespace std;struct Node{ double pos; double v;}dog[15];double cal(double v,double dogv){ if(v>0&&dogv>0) { if(v>dogv) return v-dogv; else return 0; } if(v<0&&dogv<0) { if(v
dog[i].pos) v=-fabs(v); if(posp
View Code

模拟题,水题。

考虑dogv=0的这种情况。

转载地址:http://koxxa.baihongyu.com/

你可能感兴趣的文章
大数据学习前奏之Linux
查看>>
nodejs调试指南
查看>>
重学数据结构(三):线性表的算法实现(JS)
查看>>
Java时间戳与时间的相互转换(只是为了记住才写,望原谅)
查看>>
superset 接入可视化echarts图表
查看>>
[黑客编程新书推荐]《Windows 黑客编程技术详解》上市啦
查看>>
Hive使用必知必会系列
查看>>
文章描述
查看>>
java并发简述
查看>>
Git hub
查看>>
Redis集群(一)安装配置和简便槽分配
查看>>
android studio: failed: Connection refused: connect
查看>>
SpringCloud微服务基础
查看>>
LinkedHashSet
查看>>
小猿圈之嵌入式软件工程师面试题(内含答案)
查看>>
11月30日云栖精选夜读:阿里云容器服务新增支持Kubernetes编排系统,性能重大提升...
查看>>
Unicode和UTF 8的故事
查看>>
阿里程序员相亲被嫌弃,只因穿了双特步鞋!
查看>>
Android之ListView,AsyncTask,GridView,CardView,本地数据存储,SQLite数据库
查看>>
在GDD上拿到了一块Android Things开发板,然后用它写了一个Hello World
查看>>