The problem is from codeforces: http://www.codeforces.com/problemset/problem/268/C

This problem is put at the third problem in the online contests. But it seems too easy for being in that place. The sample inputs are there to complicate the problem but if you pay attention to the problem description, you will simplify the problem as putting the maximum number of points in the rectangle area, where
and
such that
and
and
, if you multiply the
with a integer, it still is not an integer.
The solution is thus simple, place, start from (0, n) and each time, increase x and decrease y, until the point reaches the x axis. The count of the numbers is
.
#!/usr/bin/env python
n, m = map(int, raw_input().split())
k = min(n, m)
print k + 1
for x in xrange(k + 1):
print x, k - x
–EOF (The Ultimate Computing & Technology Blog) —
515 wordsLast Post: Codeforces: 268B. Buttons
Next Post: Heron's Formula for the area of a triangle
Could you provide the proof for the algorithm ??
I was struggling with this problem before I found your solution via googling. Can you please take some time to elaborate more on your solution? I can’t see how you come up with the algorithm. Thanks.