본문 바로가기

Algorithm

(2139)
(C++) - 백준(BOJ) 12833 : XORXORXOR #include using namespace std; int main() { int a, b, c; cin >> a >> b >> c; while (c--) a ^= b; cout
(C++) - 백준(BOJ)코딩 11758번 : CCW 답 www.acmicpc.net/problem/11758 11758번: CCW 첫째 줄에 P1의 (x1, y1), 둘째 줄에 P2의 (x2, y2), 셋째 줄에 P3의 (x3, y3)가 주어진다. (-10,000 ≤ x1, y1, x2, y2, x3, y3 ≤ 10,000) 모든 좌표는 정수이다. P1, P2, P3의 좌표는 서로 다르다. www.acmicpc.net 대표적인 기하 알고리즘 중 하나인 CCW입니다. ※CCW : p1,p2,p3 점에서 볼 때 선분p1p2, 선분p2p3의 외적을 이용합니다. ※외적의 정의 : AXB = a*b*sina로 정의 되는데 이뜻은 vector A를 기준으로 vector B가 얼마나 회전하려는 성질을 가지고 있는지를 표시하는 척도라고 볼 수 있습니다. 따라서 외적의 값이..
(C++) - 백준(BOJ) 10419번 : 지각 답 #include using namespace std; int ques, s, t, class_time; int main() { cin >> ques; while (ques--) { s = 0, t = 0; int ans = 0; cin >> class_time; while (1) { if (class_time < s + t) { t--; break; } t++; s = t * t; } cout
(C++) - 백준(BOJ) 10874번 : 이교수님의 시험 답 #include using namespace std; int n, a[11], ans; int main() { cin >> n; for(int i = 1; i a[j]; if (a[j] != (j-1) % 5 + 1) c = false; } if (c == true) cout
(C++) - 백준(BOJ)코딩 11098번 : 첼시를 도와줘! www.acmicpc.net/problem/11098 11098번: 첼시를 도와줘! 구단이 성적을 내지 못한다면 답은 새 선수 영입뿐이다. 이것은 오늘날 유럽 리그에서 가장 흔한 전략이고, 노르웨이의 로젠버그 팀은 이러한 전략이 성공한 대표적 예시다. 그들은 많은 스카 www.acmicpc.net 간단한 구현 문제였습니다. Code #include #include #include #include using namespace std; int main() { int n, p; cin >> n; while (n--) { cin >> p; vector s(p); int ans = 0, i = 0, ex = 0; while (p--) { cin >> s[i].first >> s[i].second; if (s[i]..
(C++) - 백준(BOJ) 10811번 : 바구니 뒤집기 https://www.acmicpc.net/problem/10811 10811번: 바구니 뒤집기 도현이는 바구니를 총 N개 가지고 있고, 각각의 바구니에는 1번부터 N번까지 번호가 순서대로 적혀져 있다. 바구니는 일렬로 놓여져 있고, 가장 왼쪽 바구니를 1번째 바구니, 그 다음 바구니를 2 www.acmicpc.net 📕 Code #include #include using namespace std; int main() { int n, m, i, j; cin >> n >> m; int *a = new int[n+1]; for (int i = 1; i > i >> j; for (int t = 0; t
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 10474번:분수 좋아해? 답 1234567891011#include using namespace std;int main() { int a, b; while (1) { cin >> a >> b; if (a == 0 && b == 0)break; cout
C++(씨쁠쁠)(cplusplus)-백준(baekjoon)(BaekJoon)코딩 5523번:경기 결과 답 1234567891011121314#include using namespace std;int a, b, ac, bc, t;int main() { cin >> t; while (t--) { cin >> a >> b; if (a > b) { ac++; } else if (a