#P7905. Constructing a Third Type of Combatant

    ID: 21090 Type: Default 1000ms 256MiB

Constructing a Third Type of Combatant

Constructing a Third Type of Combatant

You are given two types of combatants:

  • Type I: attack value a and health A.
  • Type II: attack value b and health B.

Their battle follows these rules:

  1. At any moment, if one side's health is ≤ 0 then the other side is the winner.
  2. In each round the combatant with the higher attack value strikes first.
  3. In every round each side gets one strike; the damage inflicted equals its attack value.

A new combatant, Type III, is to be constructed with attack value c and health C such that:

  • c is different from both a and b.
  • In a battle between Type I and Type II, Type II wins. In other words, the following inequality must hold: $$\left\lceil \frac{A}{b}\right\rceil + [b<a] \le \left\lceil \frac{B}{a}\right\rceil,$$ where \([x]\) equals 1 if x is true and 0 otherwise.
  • In a battle between Type II and Type III, Type III wins. This battle is modeled by: $$\left\lceil \frac{B}{c}\right\rceil + [c<b] \le \left\lceil \frac{C}{b}\right\rceil.$$
  • In a battle between Type III and Type I, Type I wins. This battle is modeled by: $$\left\lceil \frac{C}{a}\right\rceil + [a<c] \le \left\lceil \frac{A}{c}\right\rceil.$$

You are given a, A, b, B as input. If the condition for Type I vs. Type II is not satisfied then output -1 -1 immediately. Otherwise, find any pair of positive integers c and C (with c ≠ a and c ≠ b) satisfying the last two inequalities. If multiple solutions exist, output any one.


Note: In all formulas the ceiling function \(\lceil x\rceil\) is used and the indicator \([P]\) equals 1 if proposition \(P\) is true and 0 otherwise.

inputFormat

The input consists of four positive integers: a, A, b, B, separated by spaces.

outputFormat

If the condition for Type I vs. Type II (i.e. $$\left\lceil \frac{A}{b}\right\rceil + [b<a]\le\left\lceil \frac{B}{a}\right\rceil$$) is not satisfied, output -1 -1. Otherwise, output two positive integers c and C representing a valid construction for Type III combatant.

sample

5 100 10 50
11 41