본문 바로가기

Algorithm

(2139)
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 9610번:사분면 답 123456789101112131415161718192021222324#include using namespace std;int q1, q2, q3, q4, ax, x, y, t;int main() { cin >> t; while (t--) { cin >> x >> y; if (x == 0 || y == 0) { ax++; } else if (x > 0 && y > 0) q1++; else if (x 0) q2++; else if (x
(C++) - 백준(BOJ) 5054 : 주차의 신 #include #include #include #include using namespace std; int main() { int t,n; cin >> t; while (t--) { cin >> n; vector a(n); for (int i = 0; i > a[i]; sort(a.begin(),a.end()); int m = 2000000000; int tmp = 0; int sum = 0; for (int i = 0; i < n - 1; i++) sum += abs(a[i + 1] - a[i]); while (tmp++ sum) m = sum; sum -= abs(a[n - 1] - tmp) + abs(a[0] - tmp); } cout
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 9295번:주사위 답 123456789101112#include using namespace std;int main() { int a, b, t,c=0; cin >> t; while (t--) { c++; cin >> a >> b; cout
(C++) - 백준(BOJ) 10178번 : 할로윈의 사탕 답 www.acmicpc.net/problem/10178 10178번: 할로윈의 사탕 할로윈데이에 한신이네는 아부지가 사탕을 나눠주신다. 하지만 한신이의 형제들은 서로 사이가 좋지않아 서른이 넘어서도 사탕을 공정하게 나누어 주지 않으면 서로 싸움이 난다. 매년 할로윈 www.acmicpc.net 단순 수학 문제였습니다. Code #include using namespace std; int main() { int t, candy, bs; cin >> t; while (t--) { cin >> candy >> bs; cout
(C++) - 백준(BOJ) 5635번 : 생일 https://www.acmicpc.net/problem/5635 5635번: 생일 어떤 반에 있는 학생들의 생일이 주어졌을 때, 가장 나이가 적은 사람과 가장 많은 사람을 구하는 프로그램을 작성하시오. www.acmicpc.net 풀이방법 의 자료를 가진 tuple형들을 vector에 담았습니다. 그 후 더 늦게 태어난 동생부터 형순으로 정렬한 뒤 v[0]번째 위치한 학생과 v[v.size() - 1]번째 위치한 학생의 이름을 각각 출력해줬습니다. Code #include using namespace std; using tsiii = tuple ; int n; vector v; bool cmp(tsiii &a, tsiii &b){ int ad = get(a); int am = get(a); int ay..
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 2706번:초6 수학 답 1234567891011121314151617181920#include using namespace std;int GCD(int a, int b){ if (!b) { return a; } return GCD(b,a%b);}int LCM(int a, int b){ return a / GCD(a, b)*b / GCD(a, b)*GCD(a, b);}int main() { int t, a, b; cin >> t; while (t--) { cin >> a >> b; cout
(C++) - 백준(BOJ) 3034번 : 앵그리 창영 #include #include using namespace std; double n, w, h, s; int main() { cin >> n >> w >> h; while (n--) { cin >> s; if (s
(C++) - 백준(BOJ)3028번 : 창영마을 답 https://www.acmicpc.net/problem/10820 switch문을 이용해 푼 간단한 문제였습니다. 1234567891011121314151617181920212223242526#include #include #include using namespace std;string w;int a[3] = { 1,0,0 };int main() { cin >> w; for (int i = 0; i