문제 링크입니다: https://www.acmicpc.net/problem/9493
9493번: 길면 기차, 기차는 빨라, 빠른 것은 비행기
한 줄에 테스트 케이스가 하나씩 주어진다. 각 테스트 케이스는 세 개의 정수 M(1 ≤ M ≤ 10,000), A 그리고 B(1 ≤ A < B ≤ 1000)로 이루어져 있다. 정수는 공백으로 구분되어 있다. 마지막 테스트 케이
www.acmicpc.net
간단한 수학 문제였습니다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cmath> | |
using namespace std; | |
const int HOUR2SECONDS = 3600; | |
const int MINUTE2SECONDS = 60; | |
int main(void) | |
{ | |
while (1) | |
{ | |
int M, A, B; | |
cin >> M >> A >> B; | |
if (M == 0 && A == 0 && B == 0) | |
{ | |
break; | |
} | |
double aDuration = M / (double)A * HOUR2SECONDS; | |
double bDuration = M / (double)B * HOUR2SECONDS; | |
int diff = round(abs(aDuration - bDuration)); | |
printf("%d:%02d:%02d\n", diff / HOUR2SECONDS, diff % HOUR2SECONDS / MINUTE2SECONDS, diff % HOUR2SECONDS % MINUTE2SECONDS); | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 9517번 아이 러브 크로아티아 (0) | 2021.08.19 |
---|---|
백준 4562번 No Brainer (1) | 2021.07.22 |
백준 9469번 폰 노이만 (0) | 2021.07.19 |
백준 9449번 Garage (1) | 2021.07.18 |
백준 9437번 사라진 페이지 찾기 (0) | 2021.07.17 |