- 博客(7)
- 收藏
- 关注
原创 [几何]点在直线上的垂足
double dotMulti(Point e1,Point e2,Point s=org){ return ((e1.x-s.x)*(e2.x-s.x)+(e1.y-s.y)*(e2.y-s.y));}double dist(Point a,Point b=org){ return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));}double relation(
2008-11-05 15:42:00 557
原创 zju1010判断直线相交,求多边形面积
#include#includeusing namespace std;const int MAX=1001;const double EPS=1e-10;struct Point{ double x,y; Point(double a=0,double b=0):x(a),y(b){} bool operator == (Point &right) { return (fabs(x-ri
2008-10-30 16:13:00 430
原创 zju1032
一条直线((0,0),(n,m))上的格点数(包含端点)等于n与m的最大公约数+1皮克定理: 面积A和内部格点数目i、边上格点数目b的关系:A = i + b/2 - 1 #include#includestruct Point{ int x,y; Point(int a=0,int b=0):x(a),y(b){}};Point point[100],org;int size
2008-10-30 16:12:00 277
原创 矩阵求A^k,A+A^2+A^3+……A^k
void pow(int k,Matrix a){ tpow=e; //e为单位矩阵 for(;k;a=a*a,k>>=1) if(k&1)tpow=tpow*a;}Matrix sum(int k,Matrix a){ if(k==1) return a; Matrix tmp=sum(k/2,a); if(k&1) { pow(k/2
2008-10-26 11:51:00 1703
原创 2235
#include#include#includestruct Node{ int x,y; int peanuts;};int compare(const void* a,const void* b){ Node* m = (Node*) a; Node* n = (Node*) b; return n->peanuts-m->peanuts;}int main(){ const int
2008-10-07 20:53:00 361
原创 1225
#include#include#includestruct foralph{ char* origin; char* upper;};int comparenum(const void* a,const void* b){ int* m=(int*)a; int* n=(int*)b; return *m-*n;}int comparealph(const void* a,const
2008-10-07 20:51:00 260
原创 最近点对
最近的点对要不是x方向相邻,就是y方向相邻。分别按x,y方向排序,依次求距离,取最小的。#include#include#include#includeusing namespace std;struct Point{ double x,y;};bool basedX(Point& a,Point& b){ return a.x }bool basedY(Point& a,Point& b){ r
2008-05-10 16:39:00 288
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人