https://paiza.jp/works/mondai/conditions_branch/conditions_branch__complex_step8
私の回答
最初値が0のときを想定せず、何度もトライしました。
h, w = [int(x) for x in input().split()]
if h==0 and w==0:
print("NO")
elif h==0 or w==0:
print("NO")
elif h%2==0 and w%2==0:
print("YES")
else:
print("NO")
模範回答
h, w = [int(x) for x in input().split()]
if h == 0 or w == 0:
print("NO")
elif h % 2 == 0 and w % 2 == 0:
print("YES")
else:
print("NO")
- 1 つだけ注意点があります。本問は「この箱を 1 つ以上の高さ 2 、幅 2 の四角いタイルで敷き詰めます。」と書かれているため、 1 つもタイルを敷き詰められない場合はNOを出力する必要があります。 1 つもタイルを敷き詰められない場合とは、Hが 2 未満、またはWが 2 未満のときです。