Submit | All submissions | Best solutions | Back to list |
KUMAR2019 - VALENTINE |
Kumar was very excited for his Valentine's day but at the same time he was afraid about the demands of his date.
All was going good, but at last they ordered wine, waiter offered x and y unit glasses, here she got him, she said "I will drink only z unit, it's a crime not to eat a rare steak without a good glass of red wine".
Now to get the z unit out of x and y unit of glasses, Kumar starts shuffling wine from one glass to another, as it will impress her, he had to do it quick, he doesn't want to get embarrassed by calling for other glasses, or making other excuses.
Guess how he managed to serve the wine?
Input
First line contains x and y. Next line contains q number of possible values of z his date can demand.
Next q lines contain values of z.
Output
For each z, output the minimum step required to serve z unit of wine with the available glasses even if he needs to waste some or output "Damn!!" if he can't serve.
Format for output:
Case <ith query>: <answer>
Constraints
0 <= x, y <= 1000 (Yes, 0 mean waiter doesn't even serve the glasses).
0 <= z <= 2000 (0 means, she doesn't wanted to drink at all, ordering wine was just the Kumar's choice).
Example
Input: 2 3
6
0
1
2
3
4
6 Output: Case 1: 0
Case 2: 2
Case 3: 1
Case 4: 1
Case 5: 3
Case 6: Damn!!
Explanation
- Case 2: (0, 3) → (2, 1)
- Case 5: (2, 0) → (0, 2) → (2, 2)
- Case 6: He can't serve.
Added by: | ad |
Date: | 2019-02-15 |
Time limit: | 0.200s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |
Resource: | General |
hide comments
|
|||||
2019-06-01 18:24:22
Similar to problem POUR1 |
|||||
2019-03-29 07:20:13
Very poorly written question.. |
|||||
2019-03-15 07:13:33
@boemegensan 2 in 2L and 2 in 3L glass 2+3=5 hence 2 Last edit: 2019-03-15 07:14:13 |
|||||
2019-02-18 05:43:17
can you explain why wine with 4 unit can serve, although waiter only have glasses 2 and 3 units?? |
|||||
2019-02-17 09:50:22
what is the answer for this testcase 2 3 1 5 |
|||||
2019-02-16 15:21:20
Sorry for inconvenience, question statement updated. |
|||||
2019-02-16 07:09:01
According to psetter it's not embarassing at all to dump wine on the floor. Also, 0-sized glasses wasted me an hour. Trying to write a story to illustrate a problem is commendable, but please better make sure solvers don't have to figure out the curiosities of the parallel world you're setting it in. Good problem otherwise, Python passes despite silly TL. Last edit: 2019-02-16 07:19:53 |
|||||
2019-02-15 21:37:31 utkarsha gaumat
@[Lakshman] @Vipul Both glasses can be used Last edit: 2019-02-15 21:37:53 |
|||||
2019-02-15 21:27:36 [Lakshman]
@Author Can you explain the test case 5? |
|||||
2019-02-15 20:27:30 Vipul Srivastava
how will he serve 4 when he has both glasses less than 4? |