0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

ABC191 解説

Posted at

ABC191 解説

この記事は何

この記事は復習としてABC191を解説したものになります。

問題の解説

問題のリンクはこちら

A問題

A問題の公式解説のリンクはこちら

abc_312.py

B問題

B問題の公式解説のリンクはこちら
以下は自分が書いたコードになります。いわゆる「やるだけ問題」でしょう。

abc_191_b.py
N, X = map(int, input().split())
A = list(map(int, input().split()))

ans = []

for i in range(N):
    if A[i] != X:
        ans.append(A[i])

print(*ans)

ちなみに下記のようにリスト内包表記を使えば元のリストを書き換える(正確に言えば、別のオブジェクトとして代入する)ことができ、コードも短くなります。

N, X = map(int, input().split())
A = list(map(int, input().split()))

A = [i for i in A if i != X]

print(*A)

C問題

C問題の公式解説のリンクはこちら

abc_312.py

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?