Mathematics
As you can see in the problem description, you have to find numbers a & b such that (a, b) = G and [a, b] = L and also it has mentioned that if there is more than one pair satisfying the condition, output the pair for which number a is minimized. It's a very easy problem, you have to figure out whether the remainder of L / G is equal to zero or not, if so, your answer is G & L otherwise you have to output 1. Note that in the worst case (a, b) = a and these inequalities always satisfy.
(a, b) >>> GCD of a & b
[a, b] >>> LCM of a & b
(a, b) <= a (a, b) <= b [a, b] >= a
[a, b] >= b
I describe my solution or give some hints about the solution for algorithmic problems used in ICPC or online sites for programming contests.
Friday, December 25, 2009
Subscribe to:
Posts (Atom)
USACO  Prime Palindromes
I just skimmed the problem statement and panicked of the high boundary of the input, but something inside told me don't worry everyth...

Mathematics As you can see in the problem description, you have to find numbers a & b such that (a, b) = G and [a, b] = L and also it ...

Let's think about it, Have you noticed the small boundary of N & M, What can we do with this small boundary? Isn't producing al...

I don't know why, but I had a great misunderstanding of the problem statement from this sentence "FJ pours milk from one bucket t...