inblog logo
|
LHS's Study Space
    알고리즘문제풀기C#

    [알고리즘 문제 풀기] Circles Inside a Square(26326)

    C#
    lhs's avatar
    lhs
    Jun 01, 2025
    [알고리즘 문제 풀기] Circles Inside a Square(26326)
    Contents
    1. 문제 풀이 아이디어2. 나의 정답 코드 3. 정리
    www.acmicpc.net
    https://www.acmicpc.net/problem/26326
    notion image

    1. 문제 풀이 아이디어

    • 삼각형 내부 각도를 이용해 코사인 값을 계산하고, 주어진 반지름으로부터 사각형의 한 변의 길이를 구한 뒤, 넓이를 제곱하여 구해 문제를 해결할 수 있다.

    2. 나의 정답 코드

    using System.Text; StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader(Console.OpenStandardInput())) using (StreamWriter sw = new StreamWriter(Console.OpenStandardOutput())) { int n = int.Parse(sr.ReadLine()); while (n-- > 0) { double r = double.Parse(sr.ReadLine()); sb.AppendLine(Math.Pow(Math.Cos(15 * Math.PI / 180) * r * 4 + r * 2, 2).ToString("0.00000")); } sw.Write(sb); }

    3. 정리

    • Math.Cos(15 * Math.PI / 180)로 코사인 15도를 구한다.
    • 이 코사인 값을 r * 4와 곱하고, 여기에 r * 2를 더해 사각형 한 변의 길이를 구한다.
    • 해당 변의 제곱을 통해 넓이를 구하고, ToString("0.00000")로 소수점 아래 5자리까지 출력한다.
    Share article
    Contents
    1. 문제 풀이 아이디어2. 나의 정답 코드 3. 정리

    LHS's Study Space

    RSS·Powered by Inblog