Constraints 1SNS 1000 0s X, Y s N-1 0

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
5:15+ (65 O
Constraints
1SNS 1000
0s X, Ys N-1
0<K< 1000
S Input Format
The first and only line of each tes
case contains four space-
separated integers N, K, X, and Y,
denoting the number of cities, the
size of jumps, the V virus's current
city, and the city that you live in,
respectively.
E Output Format
Print YES if V virus shall reach your
city after a finite number of days,
else print NO.
O Sample #1
Input
Transcribed Image Text:5:15+ (65 O Constraints 1SNS 1000 0s X, Ys N-1 0<K< 1000 S Input Format The first and only line of each tes case contains four space- separated integers N, K, X, and Y, denoting the number of cities, the size of jumps, the V virus's current city, and the city that you live in, respectively. E Output Format Print YES if V virus shall reach your city after a finite number of days, else print NO. O Sample #1 Input
5:15 +(65
e Challenge task
The V Epidemic is spreading fast
around the world. Suppose
that there are N cities, numbered
from 0 to (N-1), arranged in a
circular manner. City 0 is
connected to city 1, to 2, .,
city (N-2) to city (N-1), and
city (N-1) to city 0.
If you know that the V virus is
currently at city X. Each day, it
jumps from its current city to the
city within a distance K to its right,
i.e., from city X to the city (X+K)%N.
As the V virus jumps, the cities in-
between don't get infected. Cities
once infected stay infected. You
live in city Y. Find if it will reach
your city eventually. If it will,
print YES, else print NO.
Transcribed Image Text:5:15 +(65 e Challenge task The V Epidemic is spreading fast around the world. Suppose that there are N cities, numbered from 0 to (N-1), arranged in a circular manner. City 0 is connected to city 1, to 2, ., city (N-2) to city (N-1), and city (N-1) to city 0. If you know that the V virus is currently at city X. Each day, it jumps from its current city to the city within a distance K to its right, i.e., from city X to the city (X+K)%N. As the V virus jumps, the cities in- between don't get infected. Cities once infected stay infected. You live in city Y. Find if it will reach your city eventually. If it will, print YES, else print NO.
Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Keywords
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education