Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | ||||
4 | 5 | 6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 | 16 | 17 |
18 | 19 | 20 | 21 | 22 | 23 | 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 |
Tags
- Set
- 이분탐색
- 문자열
- C++
- priority_queue
- 그래프
- 알고리즘
- 오블완
- 우선순위큐
- 분할정복
- 유클리드호제법
- 에라토스테네스의 체
- N과M
- int
- 백트래킹
- BFS
- stoi
- map
- 깊이우선탐색
- 백준
- DP
- Sort
- 티스토리챌린지
- 프로그래머스
- 정렬
- vector
- 다이나믹프로그래밍
- 최소공배수
- DFS
- 배열
Archives
- Today
- Total
안녕 세상아,
[백준/c++] 2941 크로아티아 알파벳 본문
https://www.acmicpc.net/problem/2941
c, d, l, n, s, z 일 때 if절로 분기 나눠서 풀면 된다.
크로아티아 숫ㅈㅏ 만나면 i++로 넘어가고 모든 조건 끝에 무조건 cnt++해주면 쉽게 풀 수 있다.
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str;
cin >> str;
int cnt = 0;
for (int i = 0; i < str.size(); i++) {
if (str[i] == 'c') {
if (str[i + 1] == '=' || str[i + 1] == '-') {
i++;
}
}
if (str[i] == 'd') {
if (str[i + 1] == 'z' && str[i + 2] == '=')
i += 2;
if (str[i + 1] == '-')
i++;
}
if (str[i] == 'l') {
if (str[i + 1] == 'j')
i++;
}
if (str[i] == 'n') {
if (str[i + 1] == 'j')
i++;
}
if (str[i] == 's') {
if (str[i + 1] == '=')
i++;
}
if (str[i] == 'z') {
if (str[i + 1] == '=')
i++;
}
cnt++;
}
cout << cnt << '\n';
}
'백준' 카테고리의 다른 글
[백준/c++] 좌표 정렬하기 (1) | 2025.01.01 |
---|---|
[백준/c++] 4673 셀프 넘버 (1) | 2024.12.28 |
[백준/c++] 2751 수 정렬하기 2 (0) | 2024.12.27 |
[백준/c++] 1316 그룹 단어 체커 (0) | 2024.12.17 |
[백준/c++] 4963 섬의 개수 (0) | 2024.11.16 |