## Leftover Eggnog

View as PDF

Points: 15 (partial)
Time limit: 5.0s
Memory limit: 64M

Author:
Problem type

What few people know is that Inaho is a fan of eggnog. He's also a fan of sales. It stands to reason, therefore, that the last time eggnog was on sale Inaho stockpiled dozens of cartons of eggnog. With the holiday season drawing to a close, he's found himself left with many a carton of eggnog nearing its expiration date. Since Inaho doesn't like expired eggnog, he's decided to serve the eggnog at the New Year's party he'll soon be attending.

Inaho has a large assortment of eggnog, but he's lacking in one area: he does not have any graded container or any means to determine volume. Specifically, every person who wants eggnog wants exactly milliliters of it, but without a way to measure eggnog Inaho has looked to you for help in distributing his eggnog.

He has two cups with which to handle eggnog in, and . He knows can hold milliliters of eggnog, and can hold .

Inaho can perform 3 operations:

• fill I - Inaho fills cup up to the brim with eggnog. He has so much eggnog on hand that he can do this an infinite number of times.
• pour I J - Inaho pours the contents of cup into cup . Any leftover remains in cup .
• chug I - With all his festive spirit Inaho downs cup , completely emptying it.

Knowing this, he can perform any number of operations on the containers with the goal of making one contain milliliters.

Since he knows that there will be many people at the party, he'd like to streamline the serving process by knowing exactly which operations he'll perform for a given . Of course, he'd also like to perform as few operations as he can. He's busy packing his eggnog though, so he's asked you to come up with this sequence of operations for him.

#### Input Specification

The first and only line of input will contain 3 space-separated integers: , , and .

#### Output Specification

The list of operations Inaho should perform, with each item on a new line. There may be multiple shortest operation lists, and outputting any is acceptable. If it is impossible to get , output Not possible.

#### Sample Input 1

100 1000 200

#### Sample Output 1

fill A
pour A B
fill A
pour A B

#### Sample Input 2

300 500 400

#### Sample Output 2

fill B
pour B A
chug A
pour B A
fill B
pour B A

#### Sample Input 3

100 200 500

#### Sample Output 3

Not possible

• FatalEagle  commented on Jan. 5, 2015, 11:27 p.m.

• Xyene  commented on Jan. 6, 2015, 6:29 a.m.

The JVM runs under a separate sandbox (cptbox reads garbage memory), so obviously System.exit is blocked — you'd be able to exit the grading process! It's relatively easy to fix by editing the security manager used to Thread#stop() the calling thread.

• Oppenheimer  commented on Jan. 2, 2015, 3:46 p.m.

Will A be always less than B?

• snowblind  commented on Jan. 2, 2015, 3:59 p.m.

no

• BMP  commented on Jan. 2, 2015, 2:24 p.m.

msa789 thought this question was called 'eggroll'

• Xyene  commented on Jan. 2, 2015, 2:54 p.m.

I guess it could've been, but I like eggnog more.

• FatalEagle  commented on Jan. 2, 2015, 2:57 p.m.

Are you the real Inaho?

• BMP  commented on Jan. 1, 2015, 6:03 p.m.

The points aren't partial?

• FatalEagle  commented on Jan. 1, 2015, 6:10 p.m.

They are now.