Tennis is a racket sport that is played by two opposing players on S sets. Each set consists of at least K games. A set is won by a player if that player wins at least K games and at least 2 games more than the opponent. Once a set is won, the set is ended and the match continues to a new set (if any) where both players start from 0 game won for that new set. For example, let K = 6, then a set can be ended with any of the following. • P1 (Player 1) wins 6 games while P2 (Player 2) wins 3 games → P1 wins the set. • P1 wins 7 games while P2 wins 9 games → P2 wins the set. On the other hand, a set cannot be ended with any of the following. • P1 wins 6 games while P2 wins 5 games → no player wins at least 2 games more than the opponent. • P1 wins 0 game while P2 wins 5 games → no player wins K = 6 games. • P1 wins 7 games while P2 wins 0 games → the set is already ended when P1 won the first 6 games. • P1 wins 8 games while P2 wins 5 games → the set must already be ended before it reaches this state, e.g., the set can be ended at 7 − 5, 6 − 4, 6 − 3, etc. You are given K, S and N, determine whether there could be such a tennis match with S sets to ends exactly with N games. If there is such a tennis match, then output “YES” (without quotes) in a single line, otherwise, output “NO” (without quotes) in a single line. For example, let K = 4, S = 2, and N = 14. It is possible to have such a tennis match. One the possibilities is as follows. • Set 1: P1 wins 6 games while P2 wins 4 games. • Set 2: P1 wins 4 games while P2 wins 0 games. There are a total of N = 6 + 4 + 4 + 0 = 14 games on S = 2 sets where each set is won if a player won at least K = 4 games and at least 2 games more than the opponent. Input Input contains three integers K S N (2 ≤ K ≤ 109 ; 1 ≤ S, N ≤ 109 ) in a line representing the minimum number of games to win a set, the total number of sets, and the total number of games, respectively. Output Output in a line a string “YES” or “NO” (without quotes) whether it is possible to have such a tennis match. Sample Input #1 4 2 14 Sample Output #1 YES Explanation for the sample input/output #1 This is the example from the problem description. Sample Input #2 3 1 2 Sample Output #2 NO Explanation for the sample input/output # 2 To win a set, a player should win at least 3 games. In this case, the match cannot be ended with exactly 2 games. Sample Input #3 6 5 181 Sample Output #3 YES Explanation for the sample input/output # 3 One example match is as follows. • Set 1: P1 wins 6 games while P2 wins 4 games. • Set 2: P1 wins 3 games while P2 wins 6 games. • Set 3: P1 wins 5 games while P2 wins 7 games. • Set 4: P1 wins 7 games while P2 wins 5 games. • Set 5: P1 wins 70 games while P2 wins 68 games

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

Tennis is a racket sport that is played by two opposing players on S sets. Each set consists of at least K
games. A set is won by a player if that player wins at least K games and at least 2 games more than the
opponent. Once a set is won, the set is ended and the match continues to a new set (if any) where both
players start from 0 game won for that new set.
For example, let K = 6, then a set can be ended with any of the following.
• P1 (Player 1) wins 6 games while P2 (Player 2) wins 3 games → P1 wins the set.
• P1 wins 7 games while P2 wins 9 games → P2 wins the set.
On the other hand, a set cannot be ended with any of the following.
• P1 wins 6 games while P2 wins 5 games → no player wins at least 2 games more than the opponent.
• P1 wins 0 game while P2 wins 5 games → no player wins K = 6 games.
• P1 wins 7 games while P2 wins 0 games → the set is already ended when P1 won the first 6 games.
• P1 wins 8 games while P2 wins 5 games → the set must already be ended before it reaches this state,
e.g., the set can be ended at 7 − 5, 6 − 4, 6 − 3, etc.
You are given K, S and N, determine whether there could be such a tennis match with S sets to ends exactly
with N games. If there is such a tennis match, then output “YES” (without quotes) in a single line, otherwise,
output “NO” (without quotes) in a single line.
For example, let K = 4, S = 2, and N = 14. It is possible to have such a tennis match. One the possibilities
is as follows.
• Set 1: P1 wins 6 games while P2 wins 4 games.
• Set 2: P1 wins 4 games while P2 wins 0 games.
There are a total of N = 6 + 4 + 4 + 0 = 14 games on S = 2 sets where each set is won if a player won at
least K = 4 games and at least 2 games more than the opponent.
Input
Input contains three integers K S N (2 ≤ K ≤ 109
; 1 ≤ S, N ≤ 109
) in a line representing the minimum
number of games to win a set, the total number of sets, and the total number of games, respectively.
Output
Output in a line a string “YES” or “NO” (without quotes) whether it is possible to have such a tennis match.

Sample Input #1
4 2 14
Sample Output #1
YES
Explanation for the sample input/output #1
This is the example from the problem description.
Sample Input #2
3 1 2
Sample Output #2
NO
Explanation for the sample input/output # 2
To win a set, a player should win at least 3 games. In this case, the match cannot be ended with exactly 2
games.
Sample Input #3
6 5 181
Sample Output #3
YES
Explanation for the sample input/output # 3
One example match is as follows.
• Set 1: P1 wins 6 games while P2 wins 4 games.
• Set 2: P1 wins 3 games while P2 wins 6 games.
• Set 3: P1 wins 5 games while P2 wins 7 games.
• Set 4: P1 wins 7 games while P2 wins 5 games.
• Set 5: P1 wins 70 games while P2 wins 68 games

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Intelligent Machines
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
  • SEE MORE 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