#include<stdio.h>#include<algorithm>using namespace std;int m,n;int a[105],b[105];int diff,ans;int solve(int x,int y){ int temp; int d=0; temp=(x^y); if(temp&1) d++; while(temp) { if((temp>>1)&1) d++; temp>>=1; } return d;}int main(){ int T;... Read More
posted @ 2011-10-18 19:29 Because Of You Views(283) Comments(0) Diggs(0) Edit
建图过程,上面一行字母与下面一行一一对应连边,再利用KM求一个最优匹配即可#include<stdio.h>#include<string.h>#include<string>#include<vector>#include<stdlib.h>using namespace std;#define MIN(a,b) a<b?a:b#define INF 999999#define MAX 50int match[MAX];bool sx[MAX],sy[MAX];int lx[MAX],ly[MAX],map[MAX][MAX] Read More
posted @ 2011-10-18 19:28 Because Of You Views(496) Comments(0) Diggs(0) Edit
输出的时候要注意#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>#include<stdlib.h>using namespace std;const double eps = 1e-8;struct point { double x,y;}p[20010];int top;bool cmpxy(point a,point b){ if(fabs(a.y-b.y)>eps) return a.y<b.y; return a.x< Read More
posted @ 2011-10-18 19:19 Because Of You Views(283) Comments(0) Diggs(0) Edit
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>struct point{ int x,y;}p[1000];int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int onedge(int n,point *p)//多边形边上的网格点数{ int i,ret=0; for(i=0;i<n;i++) ret+=gcd(abs(p[i].x-p[(i+1)%n].x),abs(p[i]. Read More
posted @ 2011-10-18 12:36 Because Of You Views(142) Comments(0) Diggs(0) Edit
#include<stdio.h>#include<string.h>#include<math.h>#include<stdlib.h>struct point{ int x,y;}p[1000];int gcd(int a,int b){ if(b==0) return a; return gcd(b,a%b);}int onedge(int n,point *p)//多边形边上的网格点数{ int i,ret=0; for(i=0;i<n;i++) ret+=gcd(abs(p[i].x-p[(i+1)%n].x),abs(p[i]. Read More
posted @ 2011-10-18 12:22 Because Of You Views(168) Comments(0) Diggs(0) Edit
判断重心在每条凸包边上的的垂足是否在凸包边上,计算几何一般思路很清晰,就是实现起来有点烦,这里错一点,那里错一点,所以,以后决定要把几何题放最后做了第一种方法:求出垂足再判断#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;const double eps = 1e-8;struct point { double x,y; point operator - (const point& t) const { po Read More
posted @ 2011-10-18 11:07 Because Of You Views(440) Comments(0) Diggs(0) Edit