2015 AlBaath Collegiate Programming Contest A
Description
Tamer is traveling with his brother on a long highway. He sees a traffic light at a distance. He calculated that it will take him x seconds until he arrives at the traffic light, he also knows that the green light lasts for g seconds, the yellow light lasts for y seconds and the red light lasts for r seconds. Now he is wondering in what color will the light be when he arrives there?
You know he is now busy driving, so he asks you to tell him the answer! you know that the light has just turned green at the moment of his question, and that the sequence of the lights is: GREEN, YELLOW, RED and then GREEN and so on.
The first line of input contains one integer T - the number of test cases.
Each test case contains four integers x, g, y, r as described in the statement.
1 ≤ x, g, y, r ≤ 109
For each test case output a single word, "RED" or "YELLOW" or "GREEN" without the quotes.
3
5 5 2 8
7 5 2 8
16 5 2 8
YELLOW
RED
GREEN
In the samples the light changes as follows:
Light: g, g, g, g, g, y, y, r, r, r, r, r , r , r , r , g , g , g , g ...
Time : 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18...
题意:告诉我们红绿灯三种颜色的时间变化,告诉一个总时间,问经过时应该是哪种颜色
解法:总时间%红绿灯变化总时间,讨论余
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
int a,b,c,d;
cin>>t;
while(t--)
{
cin>>a>>b>>c>>d;
int mod=a%(b+c+d);
if(mod<b)
{
cout<<"GREEN"<<endl;
}
else if(mod>=b&&mod<b+c)
{
cout<<"YELLOW"<<endl;
}
else
{
cout<<"RED"<<endl;
}
}
return 0;
}
2015 AlBaath Collegiate Programming Contest A的更多相关文章
- 2015 AlBaath Collegiate Programming Contest B
Description Yaaaay, Haven't you heard the news? Bakaloria results are out! And Reem had very good gr ...
- 2015 AlBaath Collegiate Programming Contest(2月14日训练赛)
A (By ggg): 题意:一个人还有x秒到红绿灯,这个红绿灯有g秒绿灯,y秒黄 灯,r秒红灯,问你到红绿灯的时候是什么灯.值得注意的是绿 灯变黄灯时,第g秒是黄灯了. B (By Anxdada) ...
- The 2015 China Collegiate Programming Contest A. Secrete Master Plan hdu5540
Secrete Master Plan Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Othe ...
- The 2015 China Collegiate Programming Contest Game Rooms
Game Rooms Time Limit: 4000/4000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submi ...
- 2015 German Collegiate Programming Contest (GCPC 15) + POI 10-T3(12/13)
$$2015\ German\ Collegiate\ Programming\ Contest\ (GCPC 15) + POI 10-T3$$ \(A.\ Journey\ to\ Greece\ ...
- Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
E. Arrange Teams time limit per test:2 seconds memory limit per test:64 megabytes input:standard inp ...
- Gym 100952F&&2015 HIAST Collegiate Programming Contest F. Contestants Ranking【BFS+STL乱搞(map+vector)+优先队列】
F. Contestants Ranking time limit per test:1 second memory limit per test:24 megabytes input:standar ...
- The 2015 China Collegiate Programming Contest L. Huatuo's Medicine hdu 5551
Huatuo's Medicine Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others ...
- The 2015 China Collegiate Programming Contest K Game Rooms hdu 5550
Game Rooms Time Limit: 4000/4000 MS (Java/Others) Memory Limit: 65535/65535 K (Java/Others)Total ...
随机推荐
- 转:python webdriver API 之定位 frame 中的对象
在 web 应用中经常会出现 frame 嵌套的应用,假设页面上有 A.B 两个 frame,其中 B 在 A 内,那么定位 B 中的内容则需要先到 A,然后再到 B.switch_to_frame ...
- how to use automapper in c#, from cf~
[DataContract] public class GroupDto { [DataMember] public int id { get; set; } [DataMember] public ...
- Struts2.3+Spring+iBatis 初学之问题判断
小白接下来将会总结下我再学习Spring的学习过程中(ssi框架)中遇到的问题,以后会不断的进行更新. 最容易犯的问题,就是声明bean的时候,属性引用其他声明的bean的时候,name没有进行好对应 ...
- BZOJ K大数查询(分治)(Zjoi2013)
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=3110 Description 有N个位置,M个操作.操作有两种,每次操作如果是1 a b ...
- SQL2008无法连接到.\SQLEXPRESS,用户'sa'登录失败(错误18456)图文解决方法
出现问题 :标题: 连接到服务器 ------------------------------ 无法连接到 .\SQLEXPRESS. ------------------------------ ...
- 【GDI+】 线段 文字 定位的问题
遇到一个看起来很简单的问题: 给定两个点,和一组文字,希望文字显示在线的附近并且居中显示.期望像这样的效果 进一步的抽象是: 1.根据文字的长度和高度,以及两个点,来获得文字的定位点(左上角点)的 2 ...
- Vmware 10安装MAC OS X 10.9备忘
下载准备 Vmware 10 unlock-all-v120.zip (用以支持新建MAC) MAC OS X 10.9 VMWARE.rar 已经安装完成的MAC系统虚拟机镜 ...
- nginx负载均衡的实现
将一台nginx主机当作前端负载均衡服务器,后面通过交换机链接多台web服务器,提供html和php的web界面服务.通过配置前端负载均衡服务器,可以实现将html界面和php界面的分开访问,即htm ...
- android 学习随笔二十二(小结)
ADB进程 * adb指令 * adb install xxx.apk * adb uninstall 包名 * adb devices * adb start-server * adb kill-s ...
- css经典布局学习
. 布局 布局是css的重头戏,每个系统的布局都有其各自的特点.无好无坏,肯定是各有优缺点,不妨拿出几个比较典型的例子来一起分析一下.例如: 经典三列布局 Bootstrap栅格布局 百度首页布局 微 ...