Hacker News new | ask | show | jobs
by luikore 4258 days ago
The problem didn't say the price must be > 0. So they may all lowered the price to 0 after lunch time, so the price before lunch time can be $5, $7, or $35 in this case...

If the price must be > 0, assume the it is `a` cents before lunch, `b` cents after lunch, and farmers sold `x`, `y`, and `z` chickens before lunch, where `a`, `b`, `x`, `y`, `z` are all unsigned integers satisfying:

    ax + b(10-x) = 3500
    ay + b(16-y) = 3500
    az + b(26-z) = 3500
Note 10 + 16 - 26 = 0, we can sum the above equations into:

    (a-b)(x + y - z) = 3500
let c = a - b, we know that c is positive integer (price before lunch is higher than after lunch). There are two obvious facts:

1) c is a factor of 3500

2) since x + y - z <= 26, c must be >= 3500/26 = 134

We also know that 3500/c is integer, with the equations we know 10(b/c), 16(b/c), 26(b/c) are all unsigned integers, so 2b/c is unsigned integer, assume d = 2b/c, we have:

    x = 3500/c - 5d
    y = 3500/c - 8d
    z = 3500/c - 13d
Remember that we are investigating the cases of b > 0, so d > 0, so 3500/c >= 13, then we have the fact:

3) c <= 3500/13 = 269

with 1), 2), 3), c = 140, 175 or 250

when c = 140, 3500/c = 25, so d = 1, x = 25 - 5 * 1 = 20 > 10, not valid

when c = 175, 3500/c = 20, so d = 1, x = 20 - 5 * 1 = 15 > 10, not valid

when c = 250, 3500/c = 14, so d = 1, x, y, z are all valid, we get b = 125, a = 375

Answer: the price before lunch is $3.75, after lunch is $1.25