Question: There are two lights that blink at regular intervals. When each one blinks, it turns on and then immediately back off, they don't toggle. They

 There are two lights that blink at regular intervals. When each

There are two lights that blink at regular intervals. When each one blinks, it turns on and then immediately back off, they don't toggle. They are both off at timet0. The first one blinks at tp, 2 p, 3 p,. seconds; the second one blinks at t q, 2 q, 3 q seconds. Once they start, they both keep blinking forever. It is very exciting to see them blink at the same time (on the same second). But your patience is going to run out eventually, in s seconds. Will they blink at same time between t1 and t s (inclusive)? Write a program that can answer this question, quick, before they start blinking again! Light l Light 2: Second: 1 23 4 5 6 78 9 10 1 12 13 14 15 16 17 18 19 20 Light 1 Second: 2 3 4 5 6 7 8 9 10 11 Figure 1: lllustration of the sample inputs. A black circle means the light is off, a white circle means the light blinks at that second. The arrows above point out times when both lights blink. Input Format Input consists of one line containing three space-separated integers p, q, and s. The first light blinks every p seconds, the second every q seconds. The value of s represents the maximum number of seconds to consider when determining if the two lights blink at the same time. Constraints 1 s p, q s100 1 ss s 10000 Output Format Output yes if the two lights blink on the same second between time 1 and time s, or no otherwise

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!