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 |
Tags
- 알고리즘
- 컴공
- 브루트포스
- 컴퓨터공학과
- 북리뷰
- 구현
- 개발
- 오퍼레이팅시스템
- 문제풀이
- Stack
- 정석
- vector
- 코딩
- 그래프
- c++
- OS
- 정석학술정보관
- bfs
- 너비우선탐색
- 컴공과
- 자료구조
- 백준
- cs
- 스택
- 오에스
- Computer science
- DP
- 코테
- coding
- Operating System
Archives
- Today
- Total
Little Jay
[C++] 백준 4358번 - 생태학 본문
시험기간에 너무 공부가 안되서 푼 문제
KMP, Boyer-Moore, NP-Hard, NP-Complete 등등 너무 어렵다 정말
학교에서 알고리즘 과제하는데 string pattern matching 알고리즘이 너무 어려워서
string 관련 문제 하나 풀었다.
어렵지는 않은데 입력을 받을때
cin >> str을 하면 틀리고, getline(cin, str)을 해주면 맞았다
이건 또 왜 그런지 잘 모르겠다
백분율 구하는 문제라서 크게 어렵지는 않았던 문제
#include <bits/stdc++.h>
using namespace std;
map<string, float> m;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
string str;
float cnt = 0;
while (getline(cin, str)) {
cnt++;
if (m.find(str) != m.end()) {
m[str] += 1;
}
else
m[str] = 1;
}
cout << fixed;
cout.precision(4);
for (auto it = m.begin(); it != m.end(); it++) {
float val = (it->second / cnt) * 100;
cout << it->first << " ";
cout << val << endl;
}
return 0;
}
'알고리즘 > BOJ' 카테고리의 다른 글
[C++] 백준 2150번 - Strongly Connected Component (0) | 2022.07.01 |
---|---|
[C++] 백준 11404번 - 플로이드 (0) | 2022.06.04 |
[C++] 백준 2018번 - 수들의 합 5 (0) | 2022.05.23 |
[C++] 백준 12813번 - 이진수연산 (0) | 2022.05.22 |
[C++] 백준 10282번 - 해킹 (0) | 2022.05.13 |
Comments