Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
谁见过这样的程序还能WA的,欲哭无泪啊!跪求帮忙#include<stdio.h> #include<cmath> int min(int a,int b) { return a<=b?a:b; } int max(int a,int b) { return a>=b?a:b; } int main() { int l,temx,x1,y1,x2,y2,x3,y3; double area,girth,a,b,c,n,temy; while(scanf("%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x3,&y3)&&(x1||y1||x2||y2||x3||y3)) { a=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)); b=sqrt((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3)); c=sqrt((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1)); girth=(a+b+c)/2; area=sqrt(girth*(girth-a)*(girth-b)*(girth-c)); l=0; if(x1!=x2) { for(temx=min(x1,x2);temx<=max(x1,x2);temx++) { temy=y1-(x1-temx)*(1.0*(y1-y2)/(x1-x2)); if(floor(temy)==ceil(temy)) l++; } } else l=l+abs(y2-y1)+1; if(x3!=x2) { for(temx=min(x3,x2);temx<=max(x3,x2);temx++) { temy=y3-(x3-temx)*(1.0*(y3-y2)/(x3-x2)); if(floor(temy)==ceil(temy)) l++; } l-=1; } else l=l+abs(y2-y3); if(x1!=x3) { for(temx=min(x1,x3);temx<=max(x1,x3);temx++) { temy=y1-(x1-temx)*(1.0*(y1-y3)/(x1-x3)); if(floor(temy)==ceil(temy)) l++; } l-=2; } else l=l+abs(y3-y1)-1; n=area-l/2+1; printf("%.0lf\n",floor(n)); } return 0; } /*0 0 1 0 0 1 0 0 5 0 0 5 */ Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator