Sphere Online Judge

SPOJ Problem Set (partial)

2830. Integers

Problem code: INTEGER7


Find two nonnegative integers x1 and x2 so that a1 * x1 + b1 = a2 * x2 + b2 and x1 + x2 is minimized. Given that there exist x1 and x2 satisfying the above equation.

Input

  • A single line containing four integers a1, b1, a2, b2 (the integers are within the interval [0..231-1].

Output

  • Print two integers x1, x2.

Example

Input
3 4 5 5

Output
2 1

Added by:Nguyen Minh Hieu
Date:2008-07-05
Time limit:1s
Source limit:50000B
Memory limit:256MB
Cluster: Pyramid (Intel Pentium III 733 MHz)
Languages:All except: ERL JS NODEJS PERL 6
Resource:VNOI Marathon '08 - Round 4
Problem Setter: Nguyễn Minh Hiếu

© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.