POJ2653Pick-up sticks
来源:互联网 发布:mssql 备份数据库 编辑:程序博客网 时间:2024/05/22 05:09
枚举每根STICKS后面放的于其是否有焦点.
还有种VECTOR的写法,没搞出来....
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <vector>#include <algorithm>using namespace std;const double INF = 1e-8;int dcmp(double t){ if(fabs(t) < INF) return 0; if(t < 0) return -1; return 1;}struct point{ double x ,y;point (double a = 0,double b = 0){ x = a;y = b;}};typedef point Vector;point operator - (const point &a,const point &b){ return point(a.x - b.x , a.y - b.y);}double cross(point &p,point &l1,point &l2){ return ((l1.x - p.x)*(l2.y - p.y) - (l1.y - p.y)*(l2.x - p.x));}double cross(Vector a,Vector b){ return a.x * b.y - a.y * b.x;}struct segment{ point s,e; int number; segment(point a,point b,int n){s = a; e = b;number = n;} segment(){ s = point(0,0);e = point(0,0);number = 0;}};segment p[1001000];bool SegmentItersection(point a1, point a2, point b1, point b2){ double c1 = cross(a2-a1, b1-a1), c2 = cross(a2-a1, b2-a1), c3 = cross(b2-b1, a1-b1), c4 = cross(b2-b1, a2-b1); return dcmp(c1)*dcmp(c2) < 0 && dcmp(c3)*dcmp(c4) < 0;}int pcount = 0;int n;bool flag [1000010];int main(){ int n , topsize; double x1,x2,y1,y2; segment temp(point(0,0),point(0,0),0); int temp1; while(1){ scanf("%d",&n); if(n ==0 ) return 0; memset(flag,0,sizeof(flag)); for(int i = 0 ;i < n; i++) scanf("%lf%lf%lf%lf",&p[i].s.x,&p[i].s.y,&p[i].e.x,&p[i].e.y); for(int i = 0 ;i < n ;i++) for(int j = i + 1 ; j < n; j++) if(SegmentItersection(p[i].e,p[i].s,p[j].e,p[j].s)) { flag [i] =true; break; } printf("Top sticks: "); for(int i = 0; i < n; i++) if(flag[i]==0) { if(i==n-1) printf("%d.\n",i+1); else printf("%d, ",i+1); } } return 0;}
0 0
- POJ2653Pick-up sticks
- poj2653Pick-up sticks【判断线段相交】
- 计算几何入门2--poj2653Pick-up sticks
- Pick-up Sticks
- poj2653 - Pick-up sticks
- POJ Pick-up sticks
- Pick-up sticks
- Pick-up sticks
- POJ2653 Pick-up sticks
- POJ2653-Pick-up sticks
- poj2653-Pick-up sticks
- hdu1147:pick up sticks
- hdu1147(Pick-up sticks)
- poj2653 Pick-up sticks
- Pick-up sticks
- UVA_10902_Pick-up Sticks
- poj2653 Pick-up sticks
- Pick-up sticks
- JAVA UUID简介
- 守护进程编程
- Callable,Runnable比较及用法
- ubuntu文件目录详解
- 黑马程序员--月薪1W的黑马训练营.Net一期朱磊的分享:逼着自己优秀
- POJ2653Pick-up sticks
- jQuery Uploadify在ASP.NET MVC3中的使用
- 设计模式之反思(二)
- Debug时不要忘了这些原则
- eclipse开发cocos2dx 3.2环境搭建之三: ccp-tests项目编译 (this project is not a CDT project)
- Eclipse+Tomcat+Axis2配置webservice。
- 【UI布局】Android布局之weight属性解析
- iOS--蓝牙 ble4.0 CoreBluetooth
- NVIDIA社招 发布日期2014年 内部推荐名额