結果

問題 No.3151 natural math of inscribed circle
ユーザー tnakao0123
提出日時 2025-05-21 15:06:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 527 bytes
コンパイル時間 356 ms
コンパイル使用メモリ 60,488 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-06-20 03:02:24
合計ジャッジ時間 1,535 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 41
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:16:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   16 |   scanf("%d%d%d", &a, &b, &c);
      |   ~~~~~^~~~~~~~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 3151.cc:  No.3151 natural math of  inscribed circle - yukicoder
 */

#include<cstdio>
#include<cmath>
#include<algorithm>

using namespace std;

/* main */

int main() {
  int a, b, c;
  scanf("%d%d%d", &a, &b, &c);

  // Helon's formula:
  //   Let d=(a+b+c)/2 -> sqrt(d(d-a)(d-b)(d-c))

  double d = 0.5 * (a + b + c);
  double s = sqrt(d * (d - a) * (d - b) * (d - c));

  // r*a/2+r*b/2+r*c/2=s -> r*(a+b+c)/2=s -> r=s*2/(a+b+c)
  double r = s / d;

  printf("%.15lf\n", r);
  
  return 0;
}
0