본문 바로가기

Algorithm

(2139)
(C++) - 백준(BOJ)코딩 10769번 : 행복한지 슬픈지 답 www.acmicpc.net/problem/10769 10769번: 행복한지 슬픈지 승엽이는 자신의 감정을 표현하기 위해서 종종 문자 메시지에 이모티콘을 넣어 보내곤 한다. 승엽이가 보내는 이모티콘은 세 개의 문자가 붙어있는 구조로 이루어져 있으며, 행복한 얼굴을 나 www.acmicpc.net 간단한 문자열 처리 문제였습니다. Code #include #include using namespace std; int main() { string k; int happy = 0, sad = 0; getline(cin, k); for (int i = 0; i < k.size() - 2; i++) { if (k[i] == ':' && k[i + 1] == '-') { if (k[i + 2] == ')') happy..
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 13229번:Selection Sum답 123456789101112131415161718#include using namespace std;int a[100001], sum[100001];int n, m, s, e;int main() { cin >> n; for (int i = 1; i > a[i]; sum[i] = sum[i - 1] + a[i]; } cin >> m; while (m--) { cin >> s >> e; cout
(C++) - 백준(BOJ) 10974번 : 모든 순열 답 #include #include using namespace std; int main() { int n; cin >> n; int *a = new int[n]; for (int i = 0; i < n; i++) a[i] = i + 1; do { for (int i = 0; i < n; i++) cout
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2644번:촌수계산 답 최단거리를 구하는 문제입니다. BFS를 이용하여 풀었습니다 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748#include #include #include using namespace std; vector family[101];queue q;int n, m, a, b;bool c[101];int d[101]; int BFS(int x){ q.push(x); c[x] = 1; while (!q.empty()) { int x = q.front(); q.pop(); for (int i = 0; i > n; cin >> a >> b; cin >> m; while (m--) { int x, y; cin >>..
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2783번:삼각 김밥 답 123456789101112131415161718192021222324#include using namespace std;int main() { double sx, sy, x, y; double scost, ocost; int n; cin >> sx >> sy; cin >> n; scost = sx / sy * 1000; while (n--) { cin >> x >> y; ocost = x / y * 1000; if (scost > ocost) scost = ocost; } printf("%.2f\n", scost);}cs
(C++) - 백준(BOJ) 2684 : 동전 게임 답 #include #include using namespace std; int coin[8],p; string c; int main() { cin >> p; while (p--) { cin >> c; for (int i = 0; i < 8; i++) coin[i] = 0; for (int i = 0; i < 38; i++) { if (c[i] == 'H')//앞 { if (c[i + 1] == 'H')//앞앞 { if (c[i + 2] == 'H')//앞앞앞 coin[7]++; else//앞앞뒤 coin[6]++; } else//앞뒤 { if (c[i + 2] == 'H')//앞뒤앞 coin[5]++; else//앞뒤뒤 coin[4]++; } } else//뒤 { if (c[i + 1] == 'H')//뒤..
(C++) - 백준(BOJ)1568번 : 새 답 https://www.acmicpc.net/problem/1568 별걸 다올리네요. 간단한 입출력 문제였습니다. 1234567891011121314#include using namespace std;int main() { int bird, k = 1, cnt = 0; cin >> bird; while (bird > 0) { if (k > bird) { k = 1; } bird -= k; cnt++; k++; } cout
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2954번:창영이의 일기장 답 1234567891011121314151617181920212223242526272829303132#include #include using namespace std;int main() { string k, ans = ""; getline(cin, k); int t = k.size(); bool c = false; for (int i = 0; i