2015 AlBaath Collegiate Programming Contest A
2016-09-30 17:52
411 查看
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
output
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...
题意:告诉我们红绿灯三种颜色的时间变化,告诉一个总时间,问经过时应该是哪种颜色
解法:总时间%红绿灯变化总时间,讨论余
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; }
相关文章推荐
- AlBaath Collegiate Programming Contest (2015) 总结
- 2015 AlBaath Collegiate Programming Contest(2月14日训练赛)
- 2015 AlBaath Collegiate Programming Contest(2月14日训练赛)
- 2015 AlBaath Collegiate Programming Contest B
- 带权并查集:CF-2015 ACM Arabella Collegiate Programming Contest(F题)
- Gym 100952A&&2015 HIAST Collegiate Programming Contest A. Who is the winner?【字符串,暴力】
- 【Codeforces】2015-2016 ACM-ICPC Nordic Collegiate Programming Contest (NCPC 2015) A Adjoin the Netwo
- hdu5551Huatuo's Medicine(The 2015 China Collegiate Programming Contest )
- Gym 100952B&&2015 HIAST Collegiate Programming Contest B. New Job【模拟】
- Gym 100952D&&2015 HIAST Collegiate Programming Contest D. Time to go back【杨辉三角预处理,组合数,dp】
- 2015 ACM Arabella Collegiate Programming Contest(F题)
- Codeforces Gym 2015 ACM Arabella Collegiate Programming Contest(二月十日训练赛)
- 2015 ACM Amman Collegiate Programming Contest
- Gym 100952E&&2015 HIAST Collegiate Programming Contest E. Arrange Teams【DFS+剪枝】
- The 2015 China Collegiate Programming Contest Game Rooms
- Gym 100952C&&2015 HIAST Collegiate Programming Contest C. Palindrome Again !!【字符串,模拟】
- 140 - The 12th Zhejiang Provincial Collegiate Programming Contest(浙江省赛2015)
- Gym 100952F&&2015 HIAST Collegiate Programming Contest F. Contestants Ranking【BFS+STL乱搞(map+vector)+优先队列】
- 2015 China Collegiate Programming Contest Nanyang
- Sudoku - The 2015 China Collegiate Programming Contest && UESTC 1222