Masala #1106
Aralash kasr
Islom noto'g'ri kasrlarni yomon ko'radi ya'ni sur'ati maxrajidan katta bo'lgan kasrlar. Unda N / M ko'rinishida kasr mavjud. Uni aralash kasr ko'rinishida yozing.
Misol uchun:
24/16=1+1/2
18/7 = 2+4/7
5/7 = 5/7
-10/2 = -5
-19/3 = -7+2/3
10/-3 = -4 + 2/3
-4/-2=2
Kirish faylida 1 qatorda N va M sonlari kiritiladi. \(10^{-15} \le N, M \le 10^{15}\)
Chiqish faylida sonni aralash kasr ko'rinishidagi holatini na'munadagidek chiqaring. Probelllar bo'lmasligiga e'tibor bering. Agar ifoda ma'noga ega bo'lmasa ″INF″ deb chop eting.
# | input.txt | output.txt |
---|---|---|
1 |
311 -398 |
-1+87/398 |
2 |
213 887 |
213/887 |
3 |
-81 848 |
-1+767/848 |
4 |
-715 654 |
-2+593/654 |
5 |
-221 -407 |
221/407 |