题目:

求车通过红绿灯的时间

题解:
若车过d时是绿灯,时间是总路程/速度

若车过d时是红灯,时间是总路程/速度+等红灯时间

代码:

#include<iostream>
#include <iomanip>
using namespace std;
typedef long long ll;
int main() {

double l, d, v, g, r;  // A,B距离,A到交通灯速度,车速,绿灯持续时间,红灯持续时间
    cin >> l >> d >> v >> g >> r;
    double T = (d / v);

while (T > g + r) {
        T = T - g - r;
    }

if (T < g) {  //车直接通过绿灯
        cout <<fixed<<setprecision(8)<< l / v;
    }
    else {
        cout << fixed << setprecision(8) << l / v + (g + r - T);
    }
    return 0;

}

29 B. Traffic Lights相关推荐

  1. CodeForces刷题C语言:Next Test、Spit Problem、Traffic Lights、Reconnaissance、Borze

    记录洛谷刷题C语言 一.Next Test 题面翻译 题面描述 给出 nnn 个互不相同的整数 aia_iai​ ,从小到大找第一个没有出现过的整数. 输入格式 第一行一个正整数 nnn ,之后是 n ...

  2. Traffic Lights(翻译)

    来源:https://codeforces.com/contest/29/problem/B Traffic Lights A car moves from point A to point B at ...

  3. 【SGU】103. Traffic Lights 最短路

    传送门:[SGU]103. Traffic Lights 题目大意: 在一个N个点M条边的城市里,每个点上有一个交通灯,交通灯亮B.P颜色,在离开始r的时间内交通灯会亮c颜色(c为B.P中的一种),然 ...

  4. signature=23e9377f593aff2d118917dcf0d9f6d0,Turning streams in the traffic lights system

    摘要: Observations of a currently functioning in Poland traffic lights system shows a need for it's mo ...

  5. 【codeforces 29B】Traffic Lights

    [题目链接]:http://codeforces.com/problemset/problem/29/B [题意] 一辆车; 让从A开到B; 然后速度是v; (只有在信号灯前面才能停下来..否则其他时 ...

  6. CodeForces - 29B Traffic Lights【水题】

    题目链接:https://codeforces.com/contest/29/problem/B #include <iostream> #include <cstdio> # ...

  7. TL-SSD: Detecting Traffic Lights by Single Shot Detection 论文复现

    1.按照我上一篇博客安装caffe-ssd; 2.安装开源网站提供的文档替换caffe-ssd,并重新编译caffe. 2.1.安装pycaffe cd caffe-master/python sou ...

  8. SGU 103 Traffic Lights

    http://acm.sgu.ru/problem.php?contest=0&problem=103 有条件限制的最短路问题,当且仅当点的颜色一样时可以通行否则需要等到符合条件时才可以通行. ...

  9. SGU 103 Traffic Lights【最短路】

    题目链接: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=16530 题意: 给定每个点最初的颜色,最初颜色持续时间,以 ...

最新文章

  1. 极致进化-敏捷进化型企业的未来畅想
  2. google浏览器插件安装时出错,Package is invalid: CRX HEADER INVALID
  3. linux空间管理,教你玩转Linux—磁盘管理
  4. boost::mpi模块reduce() 集合的性能测试
  5. 工业级PoE交换机是如何进行工作的?使用中要注意什么?
  6. WinForms C# :TabWebBrowser 多页面浏览器源码
  7. Eclipse Class Decompiler——Java反编译插件
  8. endnote初始化数据库支持_考前复习必备MySQL数据库(关系型数据库管理系统)
  9. hd4600黑苹果html5死机,黑苹果核显hd4400、hd4600显卡Clover引导驱动方法
  10. 怎么在手机上取消双重认证_谁知道苹果手机双重认证怎么弄?手机号都不知道谁的?...
  11. EST封面: 南方科技大学夏雨团队
  12. unity3d实现像素游戏的精确碰撞判定
  13. linux脚本乘法运算符,shell算术运算
  14. fatal: unable to access ‘https://github.com/NEGVS/the-economist-ebooks.git/‘: schannel: failed to re
  15. Deep Face Recognition读书笔记
  16. scikit-learn : LASSO
  17. dcos - marathon -lb 问题
  18. 零点城市社交电商v2.1.8.0
  19. X64dbg没有uac权限不能拖放打开文件的解决办法!
  20. Flink教程(29)- Flink内存管理

热门文章

  1. 速腾rshelios 5515惯导时间同步
  2. python实现:pdf 转换为 jpg/png/bmp
  3. RK3288 USB to Seria(PL2303)converter driver
  4. 沉睡者 - 百度推出可24时直播带货的AI虚拟数字人
  5. Spring data MongoDB 系列之一连接数据库并 插入数据
  6. win10下 yolov8 tensorrt模型加速部署【实战】
  7. NvidiaKepler开普勒Ventura13.1 驱动成功
  8. 手把手教你汇编 Debug
  9. 单片机c语言字符串赋值,单片机C语言中数组的用法
  10. 数字孪生技术助力孪生新时代与智慧城市的整合