DapSolve's blog

By DapSolve, history, 3 weeks ago, In English,

can anyone explain solution to this problem link

 
 
 
 
  • Vote: I like it
  • +4
  • Vote: I do not like it

»
3 weeks ago, # |
  Vote: I like it +9 Vote: I do not like it
My solution :
1st case: x = 0 (mod k), we can find an easy solution: p = k and q = 0
2nd case: x != 0 (mod k):
x = p * floor(x / k) + q * ceil(x / k)
x = (p + q) floor(x / k) + q (ceil(x / k) - floor(x / k))
We have x mod k != 0 so ceil(x / k) - floor(x / k) = 1
Then,
x = (p + q) floor(x / k) + q
If we can find p and q such that: p + q = k and q = x % k, then we can find a solution because
k * floor(x / k) + x % k = x
=> q = x % k and p = k - q
(you can see that these values are solution for the first case also)