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. Java基础(43):Java中的Object类与其方法(转)

    Object类 java.lang.Object java.lang包在使用的时候无需显示导入,编译时由编译器自动导入. Object类是类层次结构的根,Java中所有的类从根本上都继承自这个类. O ...

  2. URAL 1018 Binary Apple Tree(树DP)

    Let's imagine how apple tree looks in binary computer world. You're right, it looks just like a bina ...

  3. bzoj4547 小奇的集合

    当序列中最大和次大都是负数的时候,其相加会是一个更小的负数,因此答案为(Σai)+(m1+m2)*k,如果最大是正数次大是负数,那么一直相加直到两个数都为正数,当最大和次大都是正数时,做一下矩阵乘法即 ...

  4. java读properties的通用类,兼容linux和windows

    package util; import java.io.IOException; import java.io.InputStream; import java.util.Properties; / ...

  5. paper 5:支持向量机系列二: Support Vector —— 介绍支持向量机目标函数的 dual 优化推导,并得出“支持向量”的概念。

    paper 4中介绍了支持向量机,结果说到 Maximum Margin Classifier ,到最后都没有说“支持向量”到底是什么东西.不妨回忆一下上次最后一张图: 可以看到两个支撑着中间的 ga ...

  6. java 中多线程和锁的使用

    关键词: implements  实现  Runnable 类 run()  方法 注意点 : 创建类的实例 InterfaceController inter=new InterfaceContro ...

  7. 夺命雷公狗---node.js---13之Buffer的转换

    其实Buffer也是一种数据结构的东西,但实际中用得并不多,我们只需要知道常用的转换方法即可: /** * Created by leigood on 2016/8/30. */ var str = ...

  8. 一、Java基础--01

    Java基础测试题分析 第一题是关于基本的算法知识,这个很有必要去掌握以下,在学校也经常听老师们说找工作比试面试会出一些这方面的知识,我拿到的第一题是关于排序的,虽然很简单,但是我还是要提醒一下基础不 ...

  9. SqlServer 在创建数据库时候指定的初始数据库大小是不能被收缩的

    当你在SqlServer创建数据库的时候可以指定数据库文件的初始大小,比如下图中我们将新创建的数据库MyDB的大小设置成了1024MB 那么你建好的数据库的确也就会占用1024MB左右的磁盘空间 不过 ...

  10. php 缓存加速器软件

    Xcache 和 memcached 是两个不同层面的缓存,不存在可比性.Xcache 是 php 底层的缓存,它将PHP程式编译成字节码(byte code),再透过服务器上安装对应的程式来执行PH ...