728x90
반응형
27880번: Gahui and Soongsil University station
문제
https://www.acmicpc.net/problem/27880
27880번: Gahui and Soongsil University station
Soongsil University Station is famous as the deepest station on Seoul Subway Line 7. This station is so deep that the platform is on the B6. Gahui was surprised that she did not reach the platform after more than five minutes from the exit. Gahui wants to
www.acmicpc.net
풀이
에스컬레이터로 x걸음인 경우 한 걸음에 21cm이므로 21 * x를 추가하고, 계단으로 x걸음인 경우 한 걸음에 17cm이므로 17 * x를 추가한다. 누적된 수가 지하철 역의 깊이이며 정답이 된다.
코드
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
string s;
int x, ans = 0;
while (cin >> s >> x)
if (s == "Es")
ans += 21 * x;
else
ans += 17 * x;
cout << ans;
return 0;
}
728x90
반응형
'Problem Solving > BOJ' 카테고리의 다른 글
[백준 / BOJ] C++ 6497 전력난 (6) | 2023.04.11 |
---|---|
[백준 / BOJ] C++ 27939 가지 교배 (12) | 2023.04.10 |
[백준 / BOJ] C++ 3780 네트워크 연결 (2) | 2023.04.08 |
[백준 / BOJ] C++ 4343 Arctic Network (2) | 2023.04.07 |
[백준 / BOJ] C++ 10775 공항 (4) | 2023.04.06 |