문제 링크입니다: https://www.acmicpc.net/problem/4635
4635번: Speed Limit
The input consists of one or more data sets. Each set starts with a line containing an integer n, 1 ≤ n ≤ 10, followed by n pairs of values, one pair per line. The first value in a pair, s, is the speed in miles per hour and the second value, t, is t
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> | |
using namespace std; | |
int main(void) | |
{ | |
ios_base::sync_with_stdio(0); | |
cin.tie(0); | |
while (1) | |
{ | |
int n; | |
cin >> n; | |
if (n == -1) | |
{ | |
break; | |
} | |
int pastT = 0; | |
int miles = 0; | |
for (int i = 0; i < n; i++) | |
{ | |
int s, t; | |
cin >> s >> t; | |
miles += s * (t - pastT); | |
pastT = t; | |
} | |
cout << miles << " miles\n"; | |
} | |
return 0; | |
} |


개발환경:Visual Studio 2017
지적, 조언, 질문 환영입니다! 댓글 남겨주세요~
반응형
'알고리즘 > BOJ' 카테고리의 다른 글
백준 4690번 완전 세제곱 (0) | 2021.05.16 |
---|---|
백준 4655번 Hangover (0) | 2021.05.16 |
백준 4623번 Copier Reduction (0) | 2021.05.16 |
백준 4619번 루트 (0) | 2021.05.15 |
백준 4504번 배수 찾기 (0) | 2021.05.15 |