#include<iostream> #define MAX 10 using namespace std; typedef struct Point { int x,y; }point; typedef struct Triange { int vexnum; int vex; point pqq[MAX]; }triange; double triange_area(triange &t) { double s=(t.pqq[1].x*t.pqq[2].y+t.pqq[2].x*t.pqq[3].y+t.pqq[3].x*t.pqq[1].y -t.pqq[2].x*t.pqq[1].y-t.pqq[3].x*t.pqq[2].y-t.pqq[1].x*t.pqq[3].y)*1.0/2; return s>0? s:-s; } int GCD(int x,int y) { if(y==0)return x; else return GCD(y,x%y); } int main() { int n,i,j,k,a,b; triange p; while(cin>>p.pqq[1].x>>p.pqq[1].y>>p.pqq[2].x>>p.pqq[2].y>>p.pqq[3].x>>p.pqq[3].y&&(p.pqq[1].x||p.pqq[1].y||p.pqq[2].x||p.pqq[2].y||p.pqq[3].x||p.pqq[3].y)) { p.vexnum=3; p.vex=0; p.pqq[0].x=0; p.pqq[0].y=0; for(i=2;i<=p.vexnum;i++) { a=p.pqq[i].x-p.pqq[i-1].x; b=p.pqq[i].y-p.pqq[i-1].y; p.vex+=GCD(abs(a),abs(b)); } a=p.pqq[3].x-p.pqq[1].x; b=p.pqq[3].y-p.pqq[1].y; p.vex+=GCD(abs(a),abs(b)); double s=triange_area(p); //参数未改过来小毛病 搞了10分钟 //pick()定理 double ans=s+1-p.vex*1.0/2; printf("%.0lf/n",ans);//cout<<ans<<endl;最后一个错误 } system("pause"); return 0; } http://acm.pku.edu.cn/JudgeOnline/problem?id=2954