문제 링크입니다: www.acmicpc.net/problem/2765
2765번: 자전거 속도
입력은 여러 줄의 데이터로 구성된다. 각 데이터는 지름, 회전수, 시간이 공백으로 구분되어 주어진다. 지름은 inch단위의 실수이며, 회전수는 정수이다. 시간은 초단위의 실수로 주어진다. 입력
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 <iomanip> | |
using namespace std; | |
const double PI = 3.1415927; | |
const int INCH2MILE = 63360; | |
const int SECOND2HOUR = 3600; | |
double getDistance(double diameter, int rotateNum) | |
{ | |
double result = diameter / INCH2MILE * PI * rotateNum; | |
return result; | |
} | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
for (int i = 1; ; i++) | |
{ | |
double diameter, second; | |
int rotation; | |
cin >> diameter >> rotation >> second; | |
if (rotation == 0) | |
{ | |
break; | |
} | |
double distance = getDistance(diameter, rotation); | |
double milesPerHour = distance / (second / SECOND2HOUR); | |
cout << fixed << setprecision(2) << "Trip #" << i << ": " << distance << ' ' << milesPerHour << '\n'; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 21354번 Äpplen och päron (0) | 2021.04.25 |
---|---|
백준 21591번 Laptop Sticker (0) | 2021.04.25 |
백준 2754번 학점계산 (0) | 2021.04.25 |
백준 21598번 SciComLove (0) | 2021.04.25 |
백준 11444번 피보나치 수 6 (0) | 2021.04.25 |