작성일 :

문제 링크

20352번 - Circus

설명

원형 천막의 넓이가 주어질 때, 천막을 둘러싸는 울타리의 길이를 구하는 문제입니다.


접근법

원의 넓이가 a이면, 반지름 r은 a를 π로 나눈 값의 제곱근입니다.

둘레는 2πr이므로, 반지름을 구한 뒤 2π를 곱하면 됩니다.

결과는 소수점 아래 여섯 자리까지 출력합니다.



Code

C#

1
2
3
4
5
6
7
8
9
using System;

class Program {
  static void Main() {
    var a = double.Parse(Console.ReadLine()!);
    var ans = 2 * Math.PI * Math.Sqrt(a / Math.PI);
    Console.WriteLine($"{ans:F6}");
  }
}

C++

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  double a; cin >> a;
  double ans = 2.0 * M_PI * sqrt(a / M_PI);
  cout.setf(ios::fixed);
  cout.precision(6);
  cout << ans << "\n";

  return 0;
}