## Leftover Eggnog

View as PDF

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

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

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

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

• 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.

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

Will A be always less than B?

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

no

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

msa789 thought this question was called 'eggroll'

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

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

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

Are you the real Inaho?

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

The points aren't partial?

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

They are now.