Problem Description
985的红绿灯难题
Time limit: 1 SecMemory limit: 128 MB
Description
Given that the red, green and yellow lights each last r, g and y seconds, 985 finds that the light has just turned green, and he wants to know what color the light will be after x seconds.
Input
The first line contains an integer t, the number of test cases.
Each test case contains four integers x, g, y, r.
Note: 1 <= t <= 30, 1 <= x, g, r, y <= 1e9.
Output
If the light turns red after x seconds output R, if it turns green output G, otherwise output Y.
Sample Input
| |
Sample Output
| |
HINT
Traffic light order: green->yellow->red->green
Problem Analysis
A trivial sign-in problem
Just take x%(r+y+g) and work it out
Note that r+y+g can overflow int
cpp
| |
Problem link:ZZULI 1897 985 Traffic Light Problem