poj2954
来源:互联网 发布:鹏业软件网址 编辑:程序博客网 时间:2024/05/22 14:41
用nick定理
之前用的模板都是double 的= =,然后也是头一次将一堆模板删删删
tr_area这个是int 类型的,最后在处理两个/2过程同时进行,几个不同步的/2过程害得老夫debug了一小会= =
#include <cstdio>#include<iostream>#include <cstring>#include <cmath>#include <algorithm>using namespace std;struct Point { int x, y; Point() {} Point(int x, int y) { this->x = x; this->y = y; } void read() { scanf("%d%d", &x, &y); }};typedef Point Vector;Vector operator - (Vector A, Vector B) { return Vector(A.x - B.x, A.y - B.y);}bool operator < (const Point& a, const Point& b) { return a.x < b.x || (a.x == b.x && a.y < b.y);}const double eps = 1e-8;//double Dot(Vector A, Vector B) {return A.x * B.x + A.y * B.y;} //点积//double Length(Vector A) {return sqrt(Dot(A, A));} //向量的模int Cross(Vector A, Vector B) {return A.x * B.y - A.y * B.x;} //叉积int Area2(Point A, Point B, Point C) {return Cross(B - A, C - A);} //有向面积int gcd(int a,int b){ if(b==0)return a; return gcd(b,a%b);}Point p[3];int tr_area;int cnt;int main(){ while(scanf("%d%d%d%d%d%d",&p[0].x,&p[0].y,&p[1].x,&p[1].y,&p[2].x,&p[2].y)){ if(p[0].x==0&&p[0].y==0&&p[1].x==0&&p[1].y==0&&p[2].x==0&&p[2].y==0)break; cnt=0; tr_area=abs(Area2(p[0],p[1],p[2])); for(int i=0;i<3;i++){ cnt+=gcd(abs(p[i].x-p[(i+1)%3].x),abs(p[i].y-p[(i+1)%3].y)); } int ans; //cout<<tr_area<<" "<<cnt<<endl; ans=(tr_area-cnt+2)/2; printf("%d\n",ans); } system("pause"); return 0;}
0 0
- poj2954
- poj2954
- poj2954
- poj2954 - Triangle
- poj2954 Triangle
- POJ2954-Triangle
- Pick公式 POJ1265 && POJ2954
- 皮克定理 poj2954
- Poj2954 Triangle (Pick定理)
- poj2954 Triangle【Pick定理】
- [POJ2954]Triangle(计算几何)
- poj2954 && poj1265 Pick定理求面积
- poj 1265 ||poj2954 pick公式 网格
- poj2954三角形内整数点的个数
- poj1265 & poj2954(皮克定理pick)在格点上的多边形求面积公式
- poj2954-Triangle 求三角形的面积(已知三角形三点求面积)
- 搭建python编程环境
- POJ 1659-Frogs' Neighborhood(Havel-Hakimi定理-度序列构图)
- 思归
- runtime 的定义和运用
- 有小改进的最大公共子串计算
- poj2954
- Djagno入门:template之标签
- ScrollView嵌套ListView只显示一行
- JAVA中的类与类加载的顺序(好多初学者的困惑之处)
- Android蒙逼之旅----核心组件Activity
- Android Https请求详细demo
- css知识总结
- Android之Monkey压力测试
- centos下配置mysql 标准配置