Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

9th Edition

0135188148, 978-0135188149, 9781642087611

More Books

Students also viewed these Databases questions