Under construction

Still being built. Things may change

Coffee Shop 1

Time limit2sMemory limit128 MB

Summary
Simulate coffee being poured between two jars each cycle and count how many cups Dongho can still taste, printing gg if the count is 0 or over 50.
Level

Medium4 of 10

Topics
Simulation, Math, Implementation
Solved
No attempts yet

Problem

Dongho manages coffee at a coffee shop. Since the coffee is not selling well, he decides to drink the leftover coffee himself each day.

Dongho has an unusual tongue. If, earlier on the same day, he drank coffee stronger than the coffee he is drinking now, he cannot taste the current coffee. Coffee with the same concentration is not stronger, so he can still taste it.

At the start of a day, he prepares two jars, A and B, and fills both with coffee. Then he repeats the following process.

  1. Take one cup from jar A and drink it.
  2. Pour the same amount of coffee from jar B into jar A.
  3. Pour the same amount of water into jar B.

If jar A cannot provide one full cup, he cannot drink any more. If he has already drunk one cup from jar A but jar B cannot provide the same amount afterward, that already-drunk cup still counts.

Find how many cups of coffee Dongho can taste today.

Input

The first line contains the initial concentration a of jar A and the initial concentration b of jar B.

The second line contains the size Sa of jar A, the size Sb of jar B, and the cup size S, all in mL.

  • 0 <= a <= b <= 100
  • 1 <= Sa, Sb, S <= 1000
  • All input values are decimal integers.

A concentration is the number of grams of coffee powder contained in 1 liter.

Output

Print, on the first line, the number of cups Dongho can taste in hexadecimal. The hexadecimal digits A, B, C, D, E, and F must be uppercase.

If the number of cups he can taste is 0 or greater than 50, print gg.

Hint

In the first sample, the concentrations of the coffee Dongho drinks are 5, 5.5, 5.94, 6.3261, ... .

Examples1

  1. Example 1

    Input
    5 10
    100 1000 10
    
    Expected output
    13