본문 바로가기
  • Let's study
PS/백준

[C++] 백준 27880: Gahui and Soongsil University statio

by 코딩고수이고파 2023. 5. 18.

문제

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

 

해결방법

에스컬레이터에서 1 step의 높이21cm, 계단에서 1 stair의 높이17cm이다. 입력값은 이동 수단(str)한 층을 이동하는데 필요한 step 또는 stair의 수(cnt)이다. 총 5개이므로 입력4줄밖에 없다. str이 Es이면 cnt * 21을, Stair이면 cnt * 17을 더해 결과값을 출력한다. 

 

코드

#include<iostream>
#include<string>

using namespace std;

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);

	string str;
	int cnt, depth=0;

	for(int i=0;i<4;i++){
		cin >> str >> cnt;

		if (str == "Es")
			depth += cnt * 21;
		else
			depth += cnt * 17;
	}

	cout << depth;

	return 0;
}

'PS > 백준' 카테고리의 다른 글

[C++] 백준 9772: Quadrants  (0) 2023.05.20
[C++] 백준 25893: Majestic 10  (0) 2023.05.19
[C++] 백준 22155: Простая задача  (0) 2023.05.17
[C++] 백준 27890: 특별한 작은 분수  (1) 2023.05.16
[C++] 백준 5358: Football Team  (0) 2023.05.15

댓글