반응형
https://www.acmicpc.net/problem/9317
9317번: Monitor DPI
Each input line will have 3 numbers, the decimal value D, the integer value \(\text{Resolution}_{\text{Horizontal}}\), and the integer value \(\text{Resolution}_{\text{Vertical}}\). An input line of three zeroes will signify end of input
www.acmicpc.net
간단한 구현 문제였습니다.
📕 풀이방법
📔 입력 및 초기화
d, rh, rv를 선언 후 입력받습니다.
📔 풀이과정
공식에 맞춰 지역변수 w, h를 선언해 값을 구한 결과를 저장합니다.
📔 정답출력
형식에 맞게 출력해줍니다.
📕 Code
#include <bits/stdc++.h>
using namespace std;
double d, rh, rv;
int main(){
while(1){
cin >> d >> rh >> rv;
if(!d && !rh && !rv) break;
double w = 16 * d / sqrt(337);
double h = 9 * w / 16;
printf("Horizontal DPI: %.2f\n", rh / w);
printf("Vertical DPI: %.2f\n", rv / h);
}
}
*더 나은 내용을 위한 지적, 조언은 언제나 환영합니다.
'Algorithm > Implementation' 카테고리의 다른 글
(C++) - 백준(BOJ) 2083 : 럭비클럽 (0) | 2022.07.20 |
---|---|
(C++) - 백준(BOJ) 13223 : 소금폭탄 (0) | 2022.07.17 |
(C++) - 백준(BOJ) 7782 : Alien (0) | 2022.07.13 |
(C++) - 백준(BOJ) 11121 : Communication Channels (0) | 2022.07.12 |
(C++) - 백준(BOJ) 4806 : 줄 세기 (0) | 2022.07.11 |