2012年1月11日
摘要: 呃。。。。很经典的题目,由于数据量较大,2分的话会比较省时间。就是问你N个方块里面有多少个点。so easy!View Code 1 #include<iostream> 2 using namespace std; 3 int px,py; 4 struct LINE 5 { 6 int Ux, Uy, Lx, Ly; 7 }line[5002]; 8 int sum[5001]; 9 int n, m;10 11 inline int cross(int x1, int y1, int x2, int y2)12 {13 return x1*y2-y1*x2; ... 阅读全文
posted @ 2012-01-11 17:51 Dev-T 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 此题给出N组直线,每组2条直线,求出直线是否相交。如果共线则输出LINE,相交则输入点坐标,否则输出NONE.解析几何初中都学过一些,不过写成程序还真是麻烦。情况分成3种:1.看直线的横坐标是否相等。2.看直线的纵坐标是否相等。3.直接用直线公式求解。View Code 1 #include<iostream> 2 #define EPS 1e-8 3 using namespace std; 4 5 bool equal(double x, double y) 6 { 7 return x - y <= EPS && -EPS <= x - y; 8 阅读全文
posted @ 2012-01-11 17:44 Dev-T 阅读(841) 评论(0) 推荐(0) 编辑
摘要: 这题有2点要注意:一丶当n==1时,应特判输出YES二丶精度控制,当2点的距离相差小于1E-8,近似看作同一点。View Code 1 #include<iostream> 2 #include<cmath> 3 #define EPS 1e-8 4 #define MAXN 104 5 using namespace std; 6 struct point { 7 double x, y; 8 }; 9 typedef point VECTOR;10 11 struct segment {12 point p[2]; 13 }data[MAXN];14 15 ... 阅读全文
posted @ 2012-01-11 16:15 Dev-T 阅读(270) 评论(0) 推荐(0) 编辑