0
0

More than 1 year has passed since last update.

paizaラーニング「タイルの敷き詰め Python3編」

Posted at

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 未満のときです。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0