题目:pku2318
代码:计算几何+二分(AC)
//计算几何(叉积) + 二分搜索 // n m x1 y1 x2 y2. // (0 < n <= 5000) 0 < m <= 5000). #include <iostream>#include <cmath>using namespace std;#define infinity 1e20 #define EP 1e-10 const double PI = 2.0*asin(1.0); //高精度求PI struct point {double x,y;}; //点 struct line{ po...
题目链接:http://acm.pku.edu.cn/JudgeOnline/problem?id=3512
题目大意: 输入一些点,求最多有几点共线。
注意:本题的输入是比较的繁琐的,需要好好的控制。特别注意的是x,y可能是负数。
因此,当输入一个减号时,不一定是这个测试样例结束。这样容易造成WA.
思路:每次把一个顶点作为起点,计算其余点与该点所形成的直线的斜率。
然后进行排序,看斜率相同的有几个,求出最多相同斜率个数max,答案便是max+1.
代码:969ms
// 0 ≤ |X|, |Y| < 1,000,000. // No test case ...
题目:pku3348
代码:
//1 ≤ n ≤ 10000 where -1000 ≤ x, y ≤ 1000#include <iostream>#include <algorithm>#include <cmath>using namespace std;/*==================================================*\| Graham 求凸包 O(N * logN)| CALL: nr = graham(pnt, int n, res); res[]为凸包点集;\*==============================...
pku1113wall
//3 <= N <= 1000) 1 <= L <= 1000) (-10000 <= Xi, Yi <= 10000) #include <iostream>#include <algorithm>#include <cmath>using namespace std;const double pi=acos(-1.0);struct point //点 { double x,y; };double dist(point p1,point p2) //两点间的距离 { double x1=p1.x-p2.x,y1=p1.y-p2...
题目链接:pku1066(经典)
代码一:线段相交+枚举
//0 <= n <= 30 #include<iostream>#include <algorithm>#include<cmath>using namespace std;struct point{ double x,y; }; struct line{ point s, e; };double max(double a,double b){ return a>b?a:b; }double min(double a,double b){ return a<b?a:b; ...
http://acm.pku.edu.cn/JudgeOnline/problem?id=2653
//with 1 <= n <= 100000, the number of sticks for this case//these numbers are the planar coordinates of the endpoints of one stick// You may assume that there are no more than 1000 top sticks#include<iostream>#include<cmath>using namespace std...