poj 2954
来源:互联网 发布:程序员 600万 编辑:程序博客网 时间:2024/06/04 19:45
裸的PICK定理。 在结束条件上卡了一下,原来是这么写的 :while( cin>>x1>>y1>>x2>>y2>>x3>>y3&&(x1+y1+x2+y2+x3+y3))
每个数不为0的条件应该是这样: while( cin>>x1>>y1>>x2>>y2>>x3>>y3&&(x1||y1||x2||y2||x3||y3))
#include <queue>#include <stack>#include <math.h>#include <stdio.h>#include <stdlib.h>#include <iostream>#include <limits.h>#include <string.h>#include <string>#include <algorithm>using namespace std;struct point{ int x,y;};point p[3];int gcd(int n,int m)//斜率为整数时 ,退出循环。 有点没想明白。。 {return m == 0 ? n : gcd(m,n%m);}int intp_insegment(point a, point b){int aa = abs(b.y - a.y), bb = abs(b.x - a.x);if(aa == 0 && bb == 0)return 0;if(aa == 0)return bb - 1;if(bb == 0)return aa - 1;return gcd(aa, bb) - 1;}long long intp_edge(point p[],int n){long long ans = n;for(int i=0; i<n; i++)ans += intp_insegment(p[i], p[(i+1)%n]);return ans;}double area_polygon(point p[],int n){double s = 0.0;for(int i=0; i<n; i++)s += p[(i+1)%n].y *1ll* p[i].x - p[(i+1)%n].x*1ll * p[i].y;return fabs(s)/2.0;} long long intp_inpolygon(point p[],int n){double area = area_polygon(p,3);long long pinedge = intp_edge(p,3);return (long long)(area) - pinedge/2ll + 1;}int main(){int x1,y1,x2,y2,x3,y3;while( cin>>x1>>y1>>x2>>y2>>x3>>y3&&(x1||y1||x2||y2||x3||y3)){ p[0].x=x1; p[0].y=y1; p[1].x=x2; p[1].y=y2; p[2].x=x3; p[2].y=y3;long long ans = intp_inpolygon(p,3);printf("%lld\n",ans);}return 0;}
- poj 2954
- poj 2954
- poj 2954
- POJ 2954
- poj 2954
- poj 2954 Triangle
- hdu 1700 poj 2954
- poj 2954 Triangle
- POJ 2954解题报告
- POJ 2954(Pick公式)
- POJ 2954 pick公式
- poj 2954 pick定理
- poj 2954 pick定理
- POJ 2954 Triangle
- POJ 2954 pick定理
- 【POJ 2954】 Triangle
- poj 2954 Triangle
- poj 2954(pick定理)
- 【Oracle 世界一等公民视图】 认识 v$segment_statistics
- MINA经典入门例子----Time Server .
- 2012年终总结
- HDU 2922 Hotel booking(SPFA+floyd+map)
- matlab去除静音段
- poj 2954
- hdu2544-最短路
- 字符串流的使用
- matlab学习
- dip与px相互转换
- 用变量a给出下面的定义
- 在CentOS上安装ACE
- java 网络编程
- 第一篇博客