Problem Solving/BOJ

[백준 / BOJ] C++ 27880 Gahui and Soongsil University station

nageune 2023. 4. 9. 19:55
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
반응형