C++)
#include <iostream>
#include <string>
#include <regex>
using namespace std;
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
string str;
cin >> str;
str = regex_replace(str, regex("c="), "_");
str = regex_replace(str, regex("c-"), "_");
str = regex_replace(str, regex("dz="), "_");
str = regex_replace(str, regex("d-"), "_");
str = regex_replace(str, regex("lj"), "_");
str = regex_replace(str, regex("nj"), "_");
str = regex_replace(str, regex("s="), "_");
str = regex_replace(str, regex("z="), "_");
cout << str.length();
return 0;
}
Python)
import sys
st = sys.stdin.readline().rstrip()
alp = ['c=', 'c-', 'dz=', 'd-', 'lj', 'nj', 's=', 'z=']
ans = 0
for i in alp:
while i in st:
st = st.replace(i, '_')
print(len(st))'백준 1 > 기초' 카테고리의 다른 글
| [백준 1193] 분수 찾기 (C++/Python) (0) | 2020.12.05 |
|---|---|
| [백준 10250] ACM 호텔 (C++/Python) (0) | 2020.12.05 |
| [백준 16861] Harshad Numbers (C++/Python) (0) | 2020.12.05 |
| [백준 8912] Sales (C++/Python) (0) | 2020.12.05 |
| [백준 2775] 부녀회장이 될테야 (C++/Python) (0) | 2020.12.05 |