백준 알고리즘 9317번 : Monitor DPI

Zoo Da·2021년 7월 8일
0

백준 알고리즘

목록 보기
99/337
post-thumbnail

링크

https://www.acmicpc.net/problem/9317

문제

Monitor resolution is increasing fairly quickly and as a responsible consumer you want to be able to compare the Dots Per Inch (DPI) of the screens you are considering purchasing. Unfortunately for you the manufacturers don’t specify the DPI, they only specify the diagonal size in inches and the resolution in width by height. You may assume the width to height ratio is 16:9 for all screens.
문제의 전문은 문제 링크에서 직접 참조하는 것이 좋을 것 같다.

풀이법

간단한 구현문제 입니다.
영어이긴 하지만 차분하게 문제의 과정을 따라가면 별거 없는 수학문제입니다.

풀이 코드(C++)

// 9317번 : Monitor DPI(브론즈 3)

#include <iostream>
#include <algorithm>
#include <math.h>
#define fastio ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;

int main()
{
    fastio;
    while (1)
    {
        float d;
        int HorDPI, VertDPI;
        cin >> d >> HorDPI >> VertDPI;
        if (d == 0 && HorDPI == 0 & VertDPI == 0)
        {
            break;
        }
        float W = (16 * d) / sqrt(337);
        float h = (9 * W) / 16;
        float ans1 = HorDPI / W;
        float ans2 = VertDPI / h;
        printf("Horizontal DPI: %.2f\nVertical DPI: %.2f\n", ans1, ans2);
    }
    return 0;
}
profile
메모장 겸 블로그

0개의 댓글