# This problem should be classified as HARD

• This problem should be classified as HARD.

• Sure, it's definitely not so regular.

• @jedihy I agree. 7 upvotes prove it, you achieved it with zero lines of code lol

• I completely agree, elder learner.

Best regards,

• I don't think so. If you have a deep think, you'll find it's easy.
Af first, I don't understand why my solution is wrong. At last, I know z should be smaller than x + y.
Aftering thinking about it, you can reduce it to the GCD problem, than it'll become so easy to slove.

• and here is my code in Python:
class Solution(object):
def canMeasureWater(self, x, y, z):
"""
:type x: int
:type y: int
:type z: int
:rtype: bool
"""
'''
ax + by = z
a(x + y) + (b-a)y = z
'''
if z == 0:
return True
else:
pass

``````    a = 1
b = 1
if x > y:
a = x
b = y
else:
a = y
b = x
if b == 0:
if a != 0 and z%a == 0:
return True
else:
return False
else:
pass
if z > a + b:
return False
else:
pass

tmp = b
while tmp != 0:
tmp = a%b
a = b
b = tmp
if z%a == 0:
return True
else:
return False``````

• @jedihy
It's just a math question. The solution is quite straightforward if the greatest common divisor calls to minds. Here is a very funny explanation https://www.youtube.com/watch?v=0Oef3MHYEC0

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.