DMPG '19 S1 - Candy Shop Tycoon

View as PDF

Submit solution


Points: 5
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Mimi has recently found a very fun game - Candy Shop Tycoon! In this game, you are the owner of a candy store enterprise, each of which will produce some amount of candy at a constant rate.

Mimi, being a new player, only owns 3 candy shops. The first shop produces a candies per hour, the second b candies per hour, and the third c candies per hour.

She is trying to complete a quest where she must produce exactly C candies in the next 100 hours. To accomplish this, once an hour, she can tell any candy shop(s) to cease all production, or to restart production. Can you help Mimi clear this quest?

Constraints

1 \le a, b, c \le 1\,000\,000
1 \le C \le 1\,000\,000\,000

Input Specification

The first line of input will contain 3 space-separated integers: a, b, and c.
The second and final line of input will contain a single integer: C.

Output Specification

Output QUEST CLEARED if this is possible, and TRY AGAIN otherwise.

Sample Input 1

2 3 5
1000

Sample Output 1

QUEST CLEARED

Explanation for Sample Output 1

If we let all three shops produce candy, then we will produce 2+3+5 = 10 candies per hour, and running this for 100 hours gives you 10 \times 100 = 1000 candies.

Sample Input 2

1 10 20
3089

Sample Output 2

QUEST CLEARED

Explanation for Sample Output 2

If we let all three shops produce candy, then we will produce 1+10+20 = 31 candies per hour, and running this for 100 hours gives you 31 \times 100 = 3100 candies.
Shutting off the first and second shops for 1 hour gives you 1 \times 99 + 10 \times 99 + 20 \times 100 = 3089 total candies.

Sample Input 3

2 4 6
7

Sample Output 3

TRY AGAIN

Comments

There are no comments at the moment.