АВТ
Language:

Remote Training on Programming

Problems On-line status Contests FAQ
For authors:
Register  ||  Login
 
Hello, Guest! Login or register.

469. Linear combination

Time Limit: 1 seconds
Memory Limit:1000KB
Points:10
View Problem Statistics Submit Problem added Undefined

Имеется выражение ax+by, где a,b,x,y - целые. Коэффициенты a и b заданы.
Найдите такие значения переменных x и y, при котором ax+by принимает наименьшее положительное значение.

Входные данные
В первой строка записаны два целых числа a и b, разделенные пробелом (-109 <= a,b <= 109), а и b не равны 0.

Выходные данные
Выведите два целых числа x и y, разделенных пробелом.
Поскольку решений может быть бесконечно много, выведите любое, в котором x и y укладываются в знаковый 32-битный целый тип

Пример входных данных
2 7
Пример выходных данных
4 -1

View Problem Statistics Submit Author/source: Andrianov I.A. - by exercise from textbook of Cormen, Leiserson and etc. "Introduction to Algorithms"
Sorted Problems / Mathematics / Theory of numbers /
467. I - Pipeline 469. 482. Multiple with equal digits 888. Numbers 468. Power
We can all benefit by doing occasional "toy" programs, when artificial restrictions are set up, so that we are forced to push our abilities to the limit. The art of tackling miniproblems with all our energy will sharpen our talents for the real problems. Donald E. Knuth.
time generating 0.093 sec.
© Copyright VSTU, AVT, Nosov D.A.