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.

Input

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

Output

For each test case output a single word, "RED" or "YELLOW" or "GREEN" without the quotes.

Examples
input
3
5 5 2 8
7 5 2 8
16 5 2 8
output
YELLOW
RED
GREEN
Note

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的更多相关文章

  1. 2015 AlBaath Collegiate Programming Contest B

    Description Yaaaay, Haven't you heard the news? Bakaloria results are out! And Reem had very good gr ...

  2. 2015 AlBaath Collegiate Programming Contest(2月14日训练赛)

    A (By ggg): 题意:一个人还有x秒到红绿灯,这个红绿灯有g秒绿灯,y秒黄 灯,r秒红灯,问你到红绿灯的时候是什么灯.值得注意的是绿 灯变黄灯时,第g秒是黄灯了. B (By Anxdada) ...

  3. 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 ...

  4. The 2015 China Collegiate Programming Contest Game Rooms

    Game Rooms Time Limit: 4000/4000MS (Java/Others)     Memory Limit: 65535/65535KB (Java/Others) Submi ...

  5. 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\ ...

  6. 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 ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 转:python socket编程详细介绍

    Python 提供了两个基本的 socket 模块. 第一个是 Socket,它提供了标准的 BSD Sockets API. 第二个是 SocketServer, 它提供了服务器中心类,可以简化网络 ...

  2. ACdream 1128 Maze(费用流)

    题目链接:http://acdream.info/problem?pid=1128 Problem Description wuyiqi陷入了一个迷宫中,这个迷宫是由N*M个格子组成的矩阵.每个格子上 ...

  3. ligerui_ligerTree_001_第一个“树”效果

    折叠.展开.有复选框.没有复选框: 源码地址:http://download.csdn.net/detail/poiuy1991719/8571255 效果图: <%@ page languag ...

  4. C语言 单引号 双引号问题

    C语言中的单引号和双引号含义迥异,用单引号引起的一个字符实际上代表一个整数,整数值对应于该字符在编译器采用的字符集中的序列值,因此,采用ASCII字符集的编译器而言,‘a’的含义与0141或97严格一 ...

  5. 如何将扩展名为.backup的文件导入postgresql中 求步骤 新手 谢谢.

    1.到www.postgresql.org下载pgadmin这个工具,安装好2.在菜单-文件-新增服务器 名称:TEST-PGSQL(名称自己编) 主机:填上你postgresql数据库的服务器ip地 ...

  6. css 标签 垂直居中

    <!DOCTYPE html > <html xmlns="http://www.w3.org/1999/xhtml"> <head> < ...

  7. inline-block去掉空白距离的方法

    一.现象描述:inline-block形式水平呈现的元素,换行显示或空格分割的情况下,元素之间会有间距,实例如下: 使用CSS将行内元素的display设置为inline-block时,也会出现间隔: ...

  8. Qt可执行程序写入版本信息

    [1]新建Qt工程 1.1 具体新建步骤不赘述. 1.2 新建工程后文件目录如下: 1.3 留意对比一下你的代码目录,可以发现我的文件目录中多了一个rc类型的资源文件.那么,它也就是关键点. 1.4 ...

  9. linux主机vps简单性能测试

    第一,CPU.内存.硬盘检测 cat /proc/cpuinfo (查看CPU信息) cat /proc/meminfo (查看内存信息) df -lh (查看硬盘信息) 这个命令可以看到我们购买的V ...

  10. 【python cookbook】【数据结构与算法】7.让字典保持有序

    问题:创建一个字典,同时对字典做迭代或序列化操作时,也能控制其中元素的顺序: 解决方案:可以使用collections模块中的OrderedDict类来控制字典中元素的顺序.当对字典做迭代时,他会严格 ...