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
- XR Interaction Toolkit
- 구현
- VR
- 스택
- 다익스트라
- ue5
- 문자열
- Unreal Engine 5
- c++
- 백준
- 자료구조
- 정렬
- Team Fortress 2
- BFS
- 트리
- 유니티
- 그래프
- 우선순위 큐
- 그리디 알고리즘
- 누적 합
- 다이나믹 프로그래밍
- 알고리즘
- 유니온 파인드
- 브루트포스
- 재귀
- 시뮬레이션
- 투 포인터
- DFS
- 수학
- 백트래킹
Archives
- Today
- Total
1일1알
백준 11758번 CCW C++ 본문
https://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
외적을 이용,
(P2 - P1) X (P3 - P2)가 양수면 둘 사이의 각도가 (0,180) 이므로 반시계방향
음수면 둘 사이의 각도가 (180,360) 이므로 시계방향
0이면 일직선
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int x1, y1, x2, y2, x3, y3;
cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3;
int val = (x1 * y2 - x2 * y1 + x2 * y3 - x3 * y2 + x3 * y1 - x1 * y3) / 2;
int ans;
if (val > 0) ans = 1;
else if (val < 0) ans = -1;
else ans = 0;
cout << ans;
}
'알고리즘' 카테고리의 다른 글
백준 16936번 나3곱2 C++ (0) | 2023.02.03 |
---|---|
백준 13703번 물벼룩의 생존확률 C++ (0) | 2023.02.02 |
백준 24445번 알고리즘 수업 - 너비 우선 탐색 2 C++ (0) | 2023.01.31 |
백준 17952번 과제는 끝나지 않아! C++ (0) | 2023.01.30 |
백준 1240번 노드사이의 거리 C++ (0) | 2023.01.29 |