链接:

https://vjudge.net/problem/LightOJ-1311

题意:

A bird was flying on a train line, singing and passing lazy times. After a while it saw a train coming from its behind, so, it speeded up a bit, but remained calm. After a while it saw another train coming towards it from the front side. The bird remained calm thinking that the train coming towards him would be in another line. But after a while it realized that both the trains were on the same line!

So, the stupid brave bird made a plan to stop the accident. So it flew towards the train which was coming from the front side, and after touching the train the bird turned back immediately, and flew until it could touch another train. And after that it turned back, and continued this procedure. The birds' intention was to signal the drivers such that they could stop the train.

When the trains were d meter way, the drivers realized the abnormal behavior of the strange bird, and saw the opposite trains, and both drivers braked hard! But alas! They were able to stop the collision, but they managed to stop in front of each other leaving no distance. And the brave bird was dead in the middle of the trains. Thousand lives saved, but none remembered the bird.

For simplicity we denote the train (that was behind the bird) as the left train and the other one as the right train. The left train had velocity v1 m/s (meter per second) and the right train had velocity v2 m/s and they saw each other when they were d meter away. The driver in the left train made a deceleration of a1 m/s2 and the driver in the right train made a deceleration of a2 m/s2. And the trains just avoided collision. That means they just stopped when their distance was 0 meter. The bird had constant velocity of v3 m/s. And assume that the bird can turn immediately and can keep its constant velocity. When the trains were d meter away, the bird was somewhere between the trains. Your task is to find the distance covered by the brave bird (from this moment) in meters before sacrificing its life for thousand lives.

思路:

先求出两个火车间距离,再求小鸟飞行时间

代码:

#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map> using namespace std;
typedef long long LL;
const int INF = 1e9; const int MAXN = 1e6+10;
const int MOD = 1e9+7; int main()
{
int t, cnt = 0;
double v1, v2, v3, a1, a2;
scanf("%d", &t);
while(t--)
{
printf("Case %d: ", ++cnt);
scanf("%lf%lf%lf%lf%lf", &v1, &v2, &v3, &a1, &a2);
double x1 = (v1*v1)/(2*a1), x2 = (v2*v2)/(2*a2);
double t = max(v1/a1, v2/a2);
printf("%lf %lf\n", x1+x2, t*v3);
} return 0;
}

LightOJ - 1311 - Unlucky Bird(相遇问题)的更多相关文章

  1. LightOJ 1311 Unlucky Bird (物理题)

    题意:有点长,意思是说有一个鸟,在两列火车之间不停的来回飞,两列相距为d时,都开始减速,直到最后停止下来,正好是相距0米, 现在给定两列车的速度和减速时的加速度,和鸟的速度求 d 和鸟飞过的路程. 析 ...

  2. LightOJ 1268 Unlucky Strings(KMP+矩阵乘法+基础DP)

    题意 给出字符串的长度 \(n\) ,以及该字符串是由哪些小写字母组成,现给出一个坏串 \(S\) ,求存在多少种不同的字符串,使得其子串不含坏串. \(1 \leq n \leq 10^9\) \( ...

  3. LightOJ 1268 Unlucky Strings (KMP+矩阵快速幂)

    题意:给出一个字符集和一个字符串和正整数n,问由给定字符集组成的所有长度为n的串中不以给定字符串为连续子串的有多少个? 析:n 实在是太大了,如果小的话,就可以用动态规划做了,所以只能用矩阵快速幂来做 ...

  4. SDKD 2017 Summer Single Training #03

    今天的题目有 6 个. 第一题: CodeForces - 400D  Dima and Bacteria 这个题实际是不难的,难的可能在题意的理解上还有题干有点长,这个题很考察题意上面,知识点很熟悉 ...

  5. Lightoj 1071 - Baker Vai (双线程DP)

    题目连接: http://lightoj.com/volume_showproblem.php?problem=1071 题目大意: 一个n*m的格子,Baker Vai要从(1,1)到(n,m)再回 ...

  6. Flappy Bird 源码走读

    参考:https://github.com/kirualex/SprityBird 该项目基于spritekit,代码的结构很清楚,感觉用来学习spritekit非常不错. 1.项目只有一个viewC ...

  7. canvas 制作flappy bird(像素小鸟)全流程

    flappy bird制作全流程: 一.前言 像素小鸟这个简单的游戏于2014年在网络上爆红,游戏上线一段时间内appleStore上的下载量一度达到5000万次,风靡一时, 近年来移动web的普及为 ...

  8. 记一次与a标签相遇的小事

    最近做的一个项目,按钮使用的是a标签做的,样子还不错.不过正是这个a标签把我坑死了,有一个场景是点击a标签去调后台服务,为了防止用户频繁点击按钮提交,在去请求后台服务的时候肯定要先把按钮的事件给禁止掉 ...

  9. fly bird

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

随机推荐

  1. Linux下创建Oracle19C的数据库实例

    接上一篇博客,安装 Oracle19chttps://www.cnblogs.com/xuzhaoyang/p/11264557.html 切换到root用户下,切换目录到db_1,执行,遇到选择路径 ...

  2. Kafka序列化和反序列化与示例

    1.  卡夫卡序列化和反序列化 今天,在这篇Kafka SerDe文章中,我们将学习使用Kafka创建自定义序列化器和反序列化器的概念.此外,我们将了解序列化在Kafka中的工作原理以及为什么需要序列 ...

  3. 【程序人生】Oracle正式公布裁员,1600人,补偿N+6

    早些时候Oracle内部员工透漏,Oracle中国研发中心(CDC)或彻底关闭,涉及约1600名工程师的命运. 今天甲骨文正式公布裁员,整个中国研发中心关闭,补偿是全员n+6,包括北京,苏州,南京,上 ...

  4. css中常用的选择器和选择器优先级

    css常用的选择器:类选择器,id选择器,元素选择器,伪类选择器,伪元素选择器,属性选择器. 选择器的优先级由四个部分组成:0,0,0,0 一个选择器的具体优先级如下规则确定: ID选择器 加 0,1 ...

  5. Django框架之DRF get post put delete 使用简单示例 (利用序列化反序列化)

    路由配置 # 路由 from django.conf.urls import url from django.contrib import admin from app01 import views ...

  6. golang隐藏/显示window系统下的黑色命令窗(hide/show console)

    导入包import "github.com/gonutz/ide/w32" //隐藏consolefunc HideConsole(){ ShowConsoleAsync(w32. ...

  7. [LOJ2541] [PKUWC2018] 猎人杀

    题目链接 LOJ:https://loj.ac/problem/2541 Solution 很巧妙的思路. 注意到运行的过程中概率的分母在不停的变化,这样会让我们很不好算,我们考虑这样转化:假设所有人 ...

  8. [洛谷P3227][HNOI2013]切糕

    题目大意:有一个$n\times m$的切糕,每一个位置的高度可以在$[1,k]$之间,每个高度有一个代价,要求四联通的两个格子之间高度最多相差$D$,问可行的最小代价.$n,m,k,D\leqsla ...

  9. ASP.NET Core 2.1 中的 HttpClientFactory (Part 3) 使用Handler实现传出请求中间件

    原文:https://www.stevejgordon.co.uk/httpclientfactory-aspnetcore-outgoing-request-middleware-pipeline- ...

  10. ④ Python3.0字符串

    字符串无论是python或者其他语言,是最常用的数据类型之一: 这儿注意在python中可以通过使用引号( ' 或 " )来创建字符串.使用三引号('''或""" ...