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

Discussion of Problem 1430. Crime and Punishment

Show all messages Hide all messages

Just full search. ~O(sqrt(N)) in the worst case. To avoid TL before search do:
C = GCD(A,B);
A /= C;
B /= C;
N -= (N%C);
Think why you always can do this.
GOOD LUCK!
thanks so much!!!
Oh! I forgot, that after that N must be divided by C too :)
got AC now.
thanx again & HAPPY NEW YEAR!!!