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 5 years have passed since last update.

ABC085B - Kagami Mochi

Posted at

問題

https://atcoder.jp/contests/abs/tasks/abc085_b
スクリーンショット 2019-11-28 12.01.02.png

1回目

回答

重複削除のメソッドあるかな!って調べたらあったので一瞬で終わった。

N = gets.to_i
D = N.times.map{gets.to_i}
puts D.uniq.size

結果

スクリーンショット 2019-11-28 12.02.30.png

2回目

回答

せっかくなので自力で重複削除してみた

N = gets.to_i
D = N.times.map{gets.to_i}

for i in 0..(D.size-2)
  (D.size-1).step(i+1, -1) do |j|
    if D[j] == D[i]
      D.delete_at(j)
    end
  end
end

puts D.size

結果

スクリーンショット 2019-11-28 12.04.02.png
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?