Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

pick+gcd+x

Posted by Acaini at 2009-10-06 18:26:08 on Problem 2954 and last updated at 2009-10-06 18:28:16
#include<iostream>
using namespace std;
int x[4];
int y[4];
int gcd(int a,int b)
{
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main()
{
	int area;
	int b,i;
	while(scanf("%d%d%d%d%d%d",x+1,y+1,x+2,y+2,x+3,y+3)!=EOF)
	{
		if(x[1]==0 && y[1]==0 
			&& x[2]==0 && y[2]==0 
			&& x[3]==0 && y[3]==0 ) break;
		area=abs( (x[2]-x[1])*(y[3]-y[1])-(x[3]-x[1])*(y[2]-y[1]) );
		b=gcd(abs(x[2]-x[1]),abs(y[2]-y[1]))+gcd(abs(x[3]-x[2]),abs(y[3]-y[2]))+gcd(abs(x[1]-x[3]),abs(y[1]-y[3]));
		i=(area+2-b)>>1;
		printf("%d\n",i);
		
	}
	return 0;
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator