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?

DNCLで三角形の存在判定をする

0
Posted at

はじめに

この記事は 共通テスト手順記述標準言語 (DNCL) Advent Calendar 2025 の16日目の記事です。

三角形の三辺の長さa,b,cをもとに、その三角形が存在するかどうかを判定します。

三角形の存在判定方法

三角形はある辺の長さが残りの2辺の長さの和より長くなると、潰れてしまって存在できません。
つまり

\begin{equation}
\begin{cases}
a < b + c \\
b < a + c \\
c < a + b
\end{cases}
\end{equation}

です。これをaについて整理すると

\begin{cases}
a < b + c \\
b < a + c \\
c < a + b
\end{cases}
\iff |b - c| < a < b + c

image.png
画像の出典:https://math-juken.com/center/seiritujouken/

三角形の存在判定を書く

三角形の存在判定
a ← 3
b ← 4
c ← 5

もし a < b + c かつ a > max(b-c,c-b) ならば
|  「三角形は存在する」を表示する
を実行し、そうではないならば
|  「三角形は存在しない」を表示する
を実行する
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?