문제
https://www.acmicpc.net/problem/27880
해결방법
에스컬레이터에서 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 |
댓글