hdu1162 Eddy's picture

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1162#define MAX_VERTEX_NUM 105 #define INFINITY 0xffffffff #define TRUE 1 #define FALSE 0 typedef struct{ //int info; }VertexType; typedef struct{ double val; //int info; }ArcType,ArcMatrix[MAX_VERTEX...
图论 | 2011-07-20 21:04 | 阅读 1025 次 | 评论 0 条

【转】据说只有变态杀人狂才知道的36道题目(完整版,有答案)

第一题:懦弱的男人男人和女人坐皮艇在海上时,遭遇了鲨鱼,在鲨鱼离他们只有10米远的时候,男人着急的将女人推进了海里,并抽出匕首指着女人,说道,我们只能活一个!随即男人迅速划船逃离.女人很失望,对于这个懦弱自私的男人,她没有责怪他什么,只怪自己瞎了眼看上他...... 女人在默默的等待死亡, 五米,四米......鲨鱼速度很快,女人闭上了眼睛,忽然鲨鱼绕过了她,冲向皮艇,将男人拖下水,疯狂的撕咬男人,很快男人便尸骨无存.后来女人被路过的商船救了下来,女人发现船长望着海水在哭泣.女人问他哭什么?船长说出了原因,女人听后伤心欲绝,跳进海里自杀了.船长说了什么? 第二题:迷路的男孩有...
网摘 | 2010-08-11 19:17 | 阅读 1056 次 | 评论 0 条

hdu2098 分拆素数和

题目:hdu2098 代码一:105ms #include<iostream>#include<cmath>using namespace std;int prime(int x){ int i; for(i=(int)sqrt(x);i>1;i--) if(x%i==0)return 0; return 1;}int main(){ int n,i,c; while(cin>>n&amp;&amp;n) { c=0; for(i=2;i<n/2;i++) { if(prime(i)&amp;&amp;prime(...
泛型编程 | 2010-08-08 16:15 | 阅读 983 次 | 评论 0 条

pku1569Myacm Triangles

题目:pku1569 代码:计算几何(点在三角形内部)+枚举 // the number of monuments: at least 4, and at most 15#include <iostream>#include <cmath>using namespace std;const double eps=1e-10;struct point{ double x,y; };typedef point triangle[3];//=================================== //判断点p是否在三角形内部 double triangle_area...
默认分类 | 2010-08-06 14:36 | 阅读 802 次 | 评论 0 条

pku2318toys

题目: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...
计算几何 | 2010-08-05 21:48 | 阅读 741 次 | 评论 0 条

pku3512Incidental Points

题目链接: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 ...
计算几何 | 2010-08-02 21:23 | 阅读 865 次 | 评论 0 条

HDU1548A strange lift

题目链接:hdu1548 声明:本文摘自 sunkehappy#include <stdio.h>#define DEBUG 0const int N=300 ;const int Max = 10000000 ;int n, map[N][N], used[N], dis[N] ;void Dijkstra( int a, int b ){ int i, j, index, min ; for( i=1; i<=n; ++i ){ dis[i] = map[a][i] ; used[i] = 0 ; } used[a] = 1...
默认分类 | 2010-08-01 22:17 | 阅读 747 次 | 评论 0 条

pku3348cows

题目: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[]为凸包点集;\*==============================...
计算几何 | 2010-08-01 18:03 | 阅读 773 次 | 评论 0 条

pku1113wall

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...
计算几何 | 2010-08-01 11:37 | 阅读 697 次 | 评论 0 条

pku1556TheDoors

题目:pku1556 方法:直线相交判断+dijkstra算法 思路:把每个门的两点看成图中的一个点,构造一个以两点距离为权值的图(如果不可直达,记为INF), 再用dijkstra算法求出两个端点点的最短路。 注意:不要用memset初始化g,d;用memset初始化为非0值时,其值并非我们想象的,尽管那值很稳定。 如定义一个数组long a[20];memset(a,1,sizeof(a));用一个循环语句将各元素输出,其值都一样。 但并不是1,而是16843009。 //0 <= n <= 30 #include<iostream> #includ...
图论 | 2010-07-31 13:36 | 阅读 633 次 | 评论 0 条

pku1066TreasureHunt

题目链接: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; ...
计算几何 | 2010-07-30 21:01 | 阅读 770 次 | 评论 0 条

pku2653

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...
计算几何 | 2010-07-30 18:12 | 阅读 693 次 | 评论 0 条
最新评论