Problem:


Score : 200 points

Problem Statement

We have a grid with N rows and M columns of squares. Initially, all the squares are white.

There is a button attached to each row and each column.
When a button attached to a row is pressed, the colors of all the squares in that row are inverted; that is, white squares become black and vice versa.
When a button attached to a column is pressed, the colors of all the squares in that column are inverted.

Takahashi can freely press the buttons any number of times. Determine whether he can have exactly K black squares in the grid.

Constraints

1 \leq N,M \leq 1000

0 \leq K \leq NM

Input

Input is given from Standard Input in the following format:

N M K

Output

If Takahashi can have exactly K black squares in the grid, print Yes; otherwise, print No.

Sample Input 1

2 2 2

Sample Output 1

Yes

Press the buttons in the order of the first row, the first column.

Sample Input 2

2 2 1

Sample Output 2

No

Sample Input 3

3 5 8

Sample Output 3

Yes

Press the buttons in the order of the first column, third column, second row, fifth column.

Sample Input 4

7 9 20

Sample Output 4

No



Sample input:
2 2 2


Sample output:
Yes

Submission status: Runtime Error

Solution code:
M,N,K = map(int,input().split())

if M % K == 0 or N % K == 0 :
    print('Yes')
else:
    if K >= N and K <= M*(N-1) or K >= M and K <= N*(M-1):
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
M,N,K = map(int,input().split())

if M % K == 0 or N % K == 0 :
    print('Yes')
else:
    if K >= N and K <= M*(N-1) or K >= M and K <= N*(M-1)
        print('Yes')
    else:
    print('No')

Submission status: Runtime Error

Solution code:
M,N,K = map(int,input().split())

if M % K == 0 or N % K == 0 :
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
N,M,K=map(int,input().split())

x=N*M-2*K

if x==0:
    print('Yes')
else:
    for d in range(1,abs(x)+1):
        if x%d==0 and (d<newM and abs(x//d)<newM and (N-d)%2==0 and (M-x//d)%2==0):
            print('Yes')
            break
    else:
        print('No')

Submission status: Runtime Error

Solution code:
def solve(N, M, K, n, m, b):
    if n > N or m > M:
        return 0
    if b == K:
        return 1
    if 1 == solve(N, M, K, n + 1, m, b + M - 2 * m):
        return 1
    if 1 == solve(N, M, K, n, m + 1, b + N - 2 * n):
        return 1
    return 0


N, M, K = [int(i) for i in input().split()]
if 1 == solve(N, M, K, 0, 0, 0):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
# coding: utf-8
def II(): return int(input())
def ILI(): return list(map(int, input().split()))


def read():
    N, M, K = ILI()
    return N, M, K


def solve(N, M, K):
    def draw(n_count=0, m_count=0, now=0):
        if n_count == N and m_count == M:
            ret_set = set()
            ret_set.add(now)
            return ret_set
        if n_count == N:
            ret = draw(n_count, m_count + 1, now + (N - 2 * n_count))
            ret.add(now)
            return ret
        if m_count == M:
            ret = draw(n_count + 1, m_count, now + (M - 2 * m_count))
            ret.add(now)
            return ret
        ret_1 = draw(n_count + 1, m_count, now + (M - 2 * m_count))
        ret_2 = draw(n_count, m_count + 1, now + (N - 2 * n_count))
        ret = ret_1 | ret_2
        ret.add(now)
        return ret

    can_draw = draw()
    if K in can_draw:
        ans = "Yes"
    else:
        ans = "No"
    return ans


def main():
    params = read()
    print(solve(*params))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import numpy as np
data = raw_input().split()
n, m, k = map(int, data)
d = np.zeros([n+1, m+1, n, m])
for i in range(n+1):
    d[i, :, :i, :] = 1
for j in range(m+1):
    d[:, j, :, :j] += 1
d %= 2
ans = [int(d[i, j].sum()) for i in range(n+1) for j in range(m+1)]
if k in ans:
    print 'Yes'
else:
    print 'No'

Submission status: Runtime Error

Solution code:
def solve(N, M, K, n, m, b):
    if n > N or m > M:
        return 0
    if b == K:
        return 1
    if 1 == solve(N, M, K, n + 1, m, b + N - 2 * m):
        return 1
    if 1 == solve(N, M, K, n, m + 1, b + M - 2 * n):
        return 1
    return 0


N, M, K = [int(i) for i in input().split()]
if 1 == solve(N, M, K, 0, 0, 0):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import numpy as np
data = raw_input().split()
n, m, k = map(int, data)
prob = []
d = np.zeros([n+1, m+1, n, m])
for i in range(n+1):
    d[i, :, :i, :] = 1
for j in range(m+1):
    d[:, j, :, :j] += 1
d %= 2
flag = 0
for i in range(n+1):
    if flag:
        break
    for j in range(m+1):
        a = int(d[i, j].sum())
        if a == k:
            print 'Yes'
            flag = 1
            break
if not flag:
    print 'No'

Submission status: Runtime Error

Solution code:
def solve(N, M, K, n, m, b):
    if n > N or m > M or b > K:
        return 0
    if b + N - 2 * m == K or b + M - 2 * n == K:
        return 1
    if 1 == solve(N, M, K, n + 1, m, b + N - 2 * m):
        return 1
    if 1 == solve(N, M, K, n, m + 1, b + M - 2 * n):
        return 1
    return 0


N, M, K = [int(i) for i in input().split()]
if 1 == solve(N, M, K, 0, 0, 0):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline().split())
for i in xrange(n+1):
 for j in xrange(m+1):
  if i*m - b*j==k:
   ans = 'Yes'
print ans

Submission status: Runtime Error

Solution code:
from sys import stdin
ans = 'No'
n,m,k = map(int,stdin.readline())
for i in xrange(n+1):
 for j in xrange(m+1):
  if i*m - b*j==k:
   ans = 'Yes'
print ans

Submission status: Runtime Error

Solution code:
N, M, K = map(int, raw_input().split(' '))
 
for n in xrange(N+1):
  for m in xrange(M+1):
    if n*M + m*N - 2*n*m == K:
      print 'Yes'
      exit()
 
print 'No'

Submission status: Runtime Error

Solution code:
a = list(map(int,input().split()))
s = []
s[0] = a[0] * a[1] - 1
for i in range(1,n + 1):
	s[i] = s[i-1] - (2 * i) * 2
if a[2] in s:
	print('Yes')
else:
	print('No')

Submission status: Runtime Error

Solution code:
n,m,k=[int(x) for x in input().split()]
from itertools import product
from sys import exit
for i,j in product(range(n),range(m)):
    if i*m+j*(n-i)==K:
        print("Yes")
        exit()
print("No")