АВТ
Language:

Remote Training on Programming

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

35. Continued fraction

Time Limit: 1 seconds
Memory Limit:64000KB
Points:10
View Problem Statistics Submit Problem added Administrator

Дана рациональная дробь вида a/b, где a,b-натуральные числа в диапазоне от 1 до 1000. Разложите её в непрерывную дробь вида
a/b = q1+1/(q2+1/(q3+1/(q4+...+1/qn)))

Input

Числа a и b, разделёные пробелом

Output

Коэффициенты q1, q2 ... qn, разделённые пробелами

Sample

InputOutput
105 382 1 3 4 2

Из примера видно, что 105/38=2+1/(1+1/(3+1/(4+1/2)))


View Problem Statistics Submit Author/source:
Sorted Problems / Mathematics / Theory of numbers /
36. Closest fraction 35. 470. Divide into pairs 41. Divisibility 880. Doubling and increment
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.047 sec.
© Copyright VSTU, AVT, Nosov D.A.