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

2次元配列の要素数

Posted at

応用情報技術者平成30年秋期 午前問7

2次元配列 A[i,j] (i,j はいずれも0~99の値をとる)の i>j である要素 A[i,j] は全部で幾つか。

image.png

本質問では、0~99の値があるだけど、
まずは、少ない値からルールを探しましょう。

仮に、iは2とすると、1+2=3件ですね。
A[1,0]
A[2,1],A[2,0]

仮に、iは3とすると、1+2+3=6件ですね。
A[1,0]
A[2,1],A[2,0]
A[3,2],A[3,1],A[3,0]

つまりですね、iが99の場合、1+2+3+。。。+99が答えですね。
これは(1+99)×99/2=4950ですね。

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?