摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1431先判断回文,用时较少,再判断素数。最重要的。。。9989899这个数以上都是合数,擦----#include#include#includeint sushu(int a){ int i,j; for(i=2;i*ib)temp=a,a=b,b=temp; for(;a<=b&&a<=9989899;a++) { if(huiwen(a)&&sushu(a)) printf("%d\n",a); } printf("\... 阅读全文
posted @ 2013-08-20 23:32 执着追求的IT小小鸟 阅读(148) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2108这题是用矢量相乘来判断拐向的,三个点a,b,c,矢量叉乘(b-a)×(c-b)为正就左拐,否则右拐,出现右拐就是凹的#include#includeint x[1000000],y[1000000],n;int con(int a,int b,int c){ int s,x1,x2,y1,y2; x1=x[b]-x[a]; y1=y[b]-y[a]; x2=x[c]-x[b]; y2=y[c]-y[b]; s=x1*y2-y1*x2; return s>0;}i... 阅读全文
posted @ 2013-08-20 23:00 执着追求的IT小小鸟 阅读(184) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=2857这题是求关于已知前后光路上的两点,和镜面位置,求出反射点的位置。这里需要有1:两点求直线方程,即得到直线的三系数已知x1,x2,y1,y2,则a=y2-y1;b=x1-x2;c=x2*y1-x1*y2;2:已知两直线,求交点struct line{ double a,b,c;}p,s;void jiaodian(){ if(fabs(p.b)#includestruct line{ double a,b,c;}p,s;double x3, y3, x2, y2, x, ... 阅读全文
posted @ 2013-08-20 22:28 执着追求的IT小小鸟 阅读(274) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1115计算多边形内心的模板题思路从第1个顶点出发,分别连接第i, i+1个顶点组成三角形Ti,1 struct node{ double x,y;}p[1000010];double area(int a,int b,int c){ return (p[b].x-p[a].x)*(p[c].y-p[a].y)-(p[b].y-p[a].y)*(p[c].x-p[a].x);}int main(){ int t,n,i; double sumx,sumy,ar,x,y,sumarea; ... 阅读全文
posted @ 2013-08-20 15:39 执着追求的IT小小鸟 阅读(177) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1147套用模板,在链表中删掉与刚输入的这个相交的线段#include#includetypedef struct node{ int num; double x1,x2,y1,y2; struct node *next;}S;double x1[100010],x2[100010],y1[100010],y2[100010];S *l;int same(int a,int b)//这里是判断线段是否相交{ if(((x1[a]-x1[b])*(y2[b]-y1[b])-(y1[a]-y... 阅读全文
posted @ 2013-08-20 11:02 执着追求的IT小小鸟 阅读(225) 评论(0) 推荐(0) 编辑
摘要: http://acm.hdu.edu.cn/showproblem.php?pid=1276模拟的蛋疼。。。最蛋疼的是每一次都要报完,不能中途等于三个人就停下来#include#includetypedef struct node{ int num; struct node *next;}S;S *l;int n;void print(){ S *s=l->next,*q; while(s) { if(s->next==NULL) printf("%d\n",s->num); else printf("%d ",s->num); 阅读全文
posted @ 2013-08-20 10:33 执着追求的IT小小鸟 阅读(568) 评论(0) 推荐(0) 编辑