No Rules Rules

그릇 (feat. 백준, 7567번) 본문

생활/코테

그릇 (feat. 백준, 7567번)

개발하는 완두콩 2022. 10. 21. 11:50
728x90
반응형

그릇
https://www.acmicpc.net/problem/7567

 

7567번: 그릇

그릇을 바닥에 놓았을 때 그 높이는 10cm 이다. 그런데 두 개의 그릇을 같은 방향으로 포개면 그 높이는 5cm만 증가된다. 만일 그릇이 서로 반대방향으로 쌓이면 높이는 그릇만큼, 즉 10cm 늘어난다.

www.acmicpc.net

 

// woohyeon.kim
// kim519620.tistory.com
#include <iostream>
#include <string>
using namespace std;
int main(){
    ios::sync_with_stdio(false), cin.tie(NULL);
    string str;
    register int ans = 0;
    char tmp = 0;
    cin >> str;
    for(auto& ch : str){
        if(tmp == 0)
            ans += 10, tmp = ch;
        else{
            if(tmp == ch)
                ans += 5;
            else
                ans += 10, tmp = ch;
        }
    }
    cout << ans;
    return 0;
}
// *&)*@*

 

반응형

이전 문자를 저장하고 입력된 문자와 비교하는 연산 문제입니다.

728x90
반응형
Comments