ENG  RUSTimus Online Judge
Online Judge
Online contests
About Online Judge
Frequently asked questions
Site news
Problem set
Submit solution
Judge status
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
back to board

Discussion of Problem 1420. Integer-Valued Complex Division

WA 14 ???? Help
Posted by Ostap Korkuna 31 Oct 2005 12:01
I can't understand what is wrong? Maby something with calculations and rounding??? Can anyone help me? Thanks

[code deleted]

Edited by moderator 22.02.2006 00:48
Re: WA 14 ???? Help
Posted by hedgehog 21 Nov 2005 04:44
correst your x and y to:

[code deleted]

Edited by author 21.11.2005 04:45

Edited by moderator 22.02.2006 00:49
Re: WA 14 ???? Help
Posted by coderaka 8 Feb 2006 17:04
Can you tell me how to solve this problem??
Re: WA 14 ???? Help
Posted by Felix_Mate 3 Feb 2017 23:50
Утверждение: задача эквивалентна следующей: нужно найти все комплексные q с целыми коэффициентами, удовлетворяющие |a-bq|<|b|.
Если |b|=0, то решений нет
Иначе |b|>0. Тогда условие эквивалентно |a/b - z|<1. Пусть a=a1+b1i, b=a2+b2i, q=q1+q2i. Тогда получим |alfa/gamma-q1+i(beta/gamma+q2)|<1 <=> ((alfa-gamma*q1)/gamma)^2+((beta+gamma*q2)/gamma)^2<1, где gamma=a2*a2+b2*b2, alfa=(a1*a2+b1*b2)/gamma, beta=i(a2*b1-a1*b2)/gamma.
Теперь просто можно пройтись по всем q1 и q2 (они меняются от -1+alfa/gamma до 1+alfa/gamma и от -1-beta/gamma до 1-beta/gamma) и проверить условие.