https://paiza.jp/works/mondai/conditions_branch/conditions_branch__complex_boss
私の回答
“`
a,b=[int(x) for x in input().split()]
if a<0 and b<0:
print(b*b)
elif a<0 and b>0:
print(a*b)
elif a==0 or b==0:
print(0)
elif a>0 and b>0:
print(a*a)
“`
模範回答
“`
a, b = [int(x) for x in input().split()]
if a <= 0 and b >= 0:
# a から b の間に 0 が含まれる
print(a * b)
elif a > 0:
# a と b が両方とも正の数
print(a * a)
else:
# a と b が両方とも負の数
print(b * b)
“`
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 の四
https://paiza.jp/works/mondai/conditions_branch/conditions_branch__complex_step6
私の回答
“`
n,k,t=[int(x) for x in input().split()]
if (k*t)%n==0:
print(“YES”)
else:
print(“NO”)
“`
模範回答
“`
n, k, t = [int(x) for x in input().split()]
if k * t % n == 0:
print(“YES”)
else:
print(“NO”)
“`
今回は模範解答と私の回答がほぼ同じでした!!
https://paiza.jp/works/mondai/conditions_branch/conditions_branch__complex_step4
私の回答
“`
n=int(input())
array=list(map(int,input().split()))
sum=0
for i in range(n):
if array[i]%2!=0:
break
sum=sum+array[i]
print(sum)
“`
模範回答
“`
n = int(input())
a = [int(x) for x in input().split()]