Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(C)几何
来源:互联网 发布:怎么设置淘宝店logo 编辑:程序博客网 时间:2024/05/20 16:35
题意:给你N个点,求三个点使得他们围成三角形。而且这个三角形内部没有点。
题解:按照字典序排序,先选取2个点,然后枚举第三个点是否与前2点共线,我是使用斜率去判断是否在一条线上,这里注意一下不要直接求出斜率K,还是移项一下,使用乘积的形式,不然会出现除以0的情况出错
#include <set>#include <map>#include <list> #include <cmath> #include <queue> #include <vector>#include <cstdio> #include <string> #include <cstring>#include <iomanip> #include <iostream> #include <sstream>#include <algorithm>#define LL long long #define inf 0x3f3f3f3fusing namespace std;#define N 100005struct point { LL x,y; int org;};point convex[N];bool cmp(const point &x1,const point &x2){if(x2.x!=x1.x)return x1.x<x2.x;return x1.y<x2.y;}bool judge(point &x1,point &x2,point &x3){return ((x2.y-x3.y)*(x1.x-x2.x))!=((x1.y-x2.y)*(x2.x-x3.x));}int main(){#ifdef CDZSCfreopen("i.txt","r",stdin);#endifint n;while(~scanf("%d",&n)){for(int i=0;i<n;i++){scanf("%lld%lld",&convex[i].x,&convex[i].y);convex[i].org=i+1;}sort(convex,convex+n,cmp);printf("%d %d ",convex[0].org,convex[1].org);for(int i=2;i<n;i++){if(judge(convex[0],convex[1],convex[i])){printf("%d\n",convex[i].org);break;}}}return 0;}
0 0
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(C)几何
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation(思维 简单几何)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) 618C Constellation(计算几何+stl)
- CF# Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C计算几何 + D 图论
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(A、B、C、D)题解
- Codeforces - Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)C - Constellation(数学练习)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-C. Constellation(贪心+向量平行判断)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-C. Constellation(贪心+向量平行判断)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) 总结
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) G
- Codeforces Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)--C. Constellation
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined) C. Constellation
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(A)(模拟||规律)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(B)(构造,找规律)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-B. Guess the Permutation(模拟)
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)-D(DFS)
- 【IOS】分隔视图控制器 (UISplitViewController)
- 初始化mysql 用户的密码
- android prop文件解析过程
- iOS开发 ☞ Masonary适配详解
- 日期处理类 org.apache.commons.lang3.time.DateUtils
- Wunder Fund Round 2016 (Div. 1 + Div. 2 combined)(C)几何
- 酷传
- JAVA——基础语法(二)
- 堆排序
- Linux2.6.23 :sleepable RCU的实现
- android snackbar 使用
- [一般图最大匹配 带花树] BZOJ 4405
- android的armeabi和armeabi-v7a
- 黄迪明9.1