0
0

More than 1 year has passed since last update.

paizaラーニング「同値判定 Python3編」

Last updated at Posted at 2022-11-18

私の回答

n=int(input())
ans=0

a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(n):
    if a[i]==b[i]:
        ans+=1
print(ans)

模範解答

n = int(input())
a = [int(x) for x in input().split()]
b = [int(x) for x in input().split()]

ans = 0
for i in range(n):
    if a[i] == b[i]:
        ans += 1

print(ans)
  • A_i == B_iである要素の個数を計算します。
  • まずは 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