ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1043. Cover an Arc

Why I got WA?Please help me!
Posted by yellowgreen(*Jane*)^_^ 3 Apr 2003 14:56
#include<stdio.h>
#include<math.h>

double
x0,q0,x1,q1,x2,q2,a,b,c,a0,b0,c0,a1,b1,c1,cx,cq,r,minx,maxx,minq,maxq;

double roundup(double num)
{
  if((long)(num)==num)return num;
  else if(num>0)return(long)(num+1);else return(long)(num);
}

double rounddown(double num)
{
  if((long)(num)==num)return num;
  else if(num>0)return(long)(num);else return(long)(num-1);
}

int main()
{
  scanf("%lf%lf%lf%lf%lf%lf",&x0,&q0,&x1,&q1,&x2,&q2);
  minx=x0;if(minx>x1)minx=x1;
  maxx=x0;if(maxx<x1)maxx=x1;
  minq=q0;if(minq>q1)minq=q1;
  maxq=q0;if(maxq<q1)maxq=q1;
  cx=(x0+x1)/2;cq=(q0+q1)/2;
  a=q1-q0;b=x0-x1;c=x1*q0-x0*q1;
  if(a!=0){a0=b/a;b0=-1;c0=cq-a0*cx;}
    else{a0=1;b0=0;c0=-cx;}
  cx=(x0+x2)/2;cq=(q0+q2)/2;
  a=q2-q0;b=x0-x2;c=x2*q0-x0*q2;
  if(a!=0){a1=b/a;b1=-1;c1=cq-a1*cx;}
    else{a1=1;b1=0;c1=-cx;}
  cx=(b0*c1-b1*c0)/(a0*b1-a1*b0);cq=(a1*c0-a0*c1)/(a0*b1-a1*b0);
  r=sqrt((x0-cx)*(x0-cx)+(q0-cq)*(q0-cq));
  a=q1-q0;b=x0-x1;c=x1*q0-x0*q1;
  if((a*x2+b*q2+c)*(a*(cx-r)+b*cq+c)>=0)minx=cx-r;
  if((a*x2+b*q2+c)*(a*(cx+r)+b*cq+c)>=0)maxx=cx+r;
  if((a*x2+b*q2+c)*(a*cx+b*(cq-r)+c)>=0)minq=cq-r;
  if((a*x2+b*q2+c)*(a*cx+b*(cq+r)+c)>=0)maxq=cq+r;
  minx=roundup(minx);
  maxx=rounddown(maxx);
  minq=roundup(minq);
  maxq=rounddown(maxq);
  if(minx<-1000)minx=-1000;if(minq<-1000)minq=-1000;
  if(maxx>1000)maxx=1000;if(maxq>1000)maxq=1000;
  printf("%0.0lf",fabs((maxx-minx)*(maxq-minq)));
  return 0;
}
I have Ac now!
Posted by yellowgreen(*Jane*)^_^ 5 Apr 2003 12:31
> #include<stdio.h>
> #include<math.h>
>
> double
>
x0,q0,x1,q1,x2,q2,a,b,c,a0,b0,c0,a1,b1,c1,cx,cq,r,minx,maxx,minq,maxq;
>
> double roundup(double num)
> {
>   if((long)(num)==num)return num;
>   else if(num>0)return(long)(num+1);else return(long)(num);
> }
>
> double rounddown(double num)
> {
>   if((long)(num)==num)return num;
>   else if(num>0)return(long)(num);else return(long)(num-1);
> }
>
> int main()
> {
>   scanf("%lf%lf%lf%lf%lf%lf",&x0,&q0,&x1,&q1,&x2,&q2);
>   minx=x0;if(minx>x1)minx=x1;
>   maxx=x0;if(maxx<x1)maxx=x1;
>   minq=q0;if(minq>q1)minq=q1;
>   maxq=q0;if(maxq<q1)maxq=q1;
>   cx=(x0+x1)/2;cq=(q0+q1)/2;
>   a=q1-q0;b=x0-x1;c=x1*q0-x0*q1;
>   if(a!=0){a0=b/a;b0=-1;c0=cq-a0*cx;}
>     else{a0=1;b0=0;c0=-cx;}
>   cx=(x0+x2)/2;cq=(q0+q2)/2;
>   a=q2-q0;b=x0-x2;c=x2*q0-x0*q2;
>   if(a!=0){a1=b/a;b1=-1;c1=cq-a1*cx;}
>     else{a1=1;b1=0;c1=-cx;}
>   cx=(b0*c1-b1*c0)/(a0*b1-a1*b0);cq=(a1*c0-a0*c1)/(a0*b1-a1*b0);
>   r=sqrt((x0-cx)*(x0-cx)+(q0-cq)*(q0-cq));
>   a=q1-q0;b=x0-x1;c=x1*q0-x0*q1;
>   if((a*x2+b*q2+c)*(a*(cx-r)+b*cq+c)>=0)minx=cx-r;
>   if((a*x2+b*q2+c)*(a*(cx+r)+b*cq+c)>=0)maxx=cx+r;
>   if((a*x2+b*q2+c)*(a*cx+b*(cq-r)+c)>=0)minq=cq-r;
>   if((a*x2+b*q2+c)*(a*cx+b*(cq+r)+c)>=0)maxq=cq+r;
>   minx=roundup(minx);
>   maxx=rounddown(maxx);
>   minq=roundup(minq);
>   maxq=rounddown(maxq);
>   if(minx<-1000)minx=-1000;if(minq<-1000)minq=-1000;
>   if(maxx>1000)maxx=1000;if(maxq>1000)maxq=1000;
>   printf("%0.0lf",fabs((maxx-minx)*(maxq-minq)));
>   return 0;
> }
Re: I have Ac now!
Posted by mai 15 Oct 2004 19:53
??

you still wa !!

Re: I have Ac now!
Posted by Jerry 16 Aug 2007 20:49
Yes
You are still
WA!!!!!!?!!!!!!!