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

Re:求助,不管怎么调都过不了。

Posted by Yular at 2011-03-18 23:23:27 on Problem 1113
In Reply To:求助,不管怎么调都过不了。 Posted by:cjddl at 2011-02-26 16:54:38
> var
>   x,y,q:array[0..1101] of longint;
>   n,i,k,top,l,t:longint;
>   ans:real;
> 
> function cross(x1,y1,x2,y2,x3,y3:longint):longint;
> begin
>   cross:=(x2-x1)*(y3-y1)-(x3-x1)*(y2-y1);
> end;
> 
> function dis(x1,y1,x2,y2:longint):real;
> begin
>   dis:=sqrt(sqr(x2-x1)+sqr(y2-y1));
> end;
> 
> procedure sort;
> var i,j:longint;
> begin
>   for i:=2 to n-1 do begin
>     k:=i;
>     for j:=i+1 to n do
>     if (cross(x[1],y[1],x[j],y[j],x[k],y[k])>0)
>     or (cross(x[1],y[1],x[j],y[j],x[k],y[k])=0)
>     and (dis(x[1],y[1],x[j],y[j])<dis(x[1],y[1],x[k],y[k])) then k:=j;
>     t:=x[i];x[i]:=x[k];x[k]:=t;
>     t:=y[i];y[i]:=y[k];y[k]:=t;
>   end;
> end;
> 
> begin
>   readln(n,l);x[0]:=1<<30;y[0]:=x[0];
>   for i:=1 to n do begin
>     readln(x[i],y[i]);
>     if (y[i]<y[k]) or (y[i]=y[k]) and (x[i]<x[k]) then k:=i;
>   end;
>   t:=x[1];x[1]:=x[k];x[k]:=t;
>   t:=y[1];y[1]:=y[k];y[k]:=t;
>   sort;
>   q[1]:=1;q[2]:=2;q[3]:=3;top:=3;
>   for i:=4 to n do begin
>     while (cross(x[q[top-1]],y[q[top-1]],x[i],y[i],x[q[top]],y[q[top]])>=0)
>     do dec(top);
>     inc(top);q[top]:=i;
>   end;
>   q[0]:=q[top];
>   for i:=1 to top do ans:=ans+dis(x[q[i]],y[q[i]],x[q[i-1]],y[q[i-1]]);
>   writeln(round(ans+2*pi*l));
> end.
> 
> 
> 
> 如果有两个点是同一个坐标会不会有问题?

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