lantimilan's blog

By lantimilan, 11 years ago, In English

problem A:

// let (a1, a2) be the fractional pair we start and the integral target
// be (k1, k2)
// if a1 and a2 are both > 0, then k1 and k2 must be 0 and 1000
// if a1 and a2 are both = 0, then k1 = k2 = 0
// if a1 = 0 and a2 > 0, then we can make 0, 1000 or 0,0
//
// in other words, target is always 1000 unless we have a1 = 0
// we have n pairs, we can get as many as #zero of 0s
// we can get as little as (#zero — other) /2,
// notice that #zero and other must be same parity, because the sum
// of the two is 2n, an even number
//
// we can try all possible number of 0s for target, the rest is 1000
//

Full text and comments »

  • Vote: I like it
  • -16
  • Vote: I do not like it