URAL 1020 Rope

我不知道该怎么证明围在钉子周围的非直线弧总和为什么是2*PI*R。

谁能帮我证明它。。。

[报告]

    比较裸的凸包问题,只是要考虑当N=1的情况。

    把凸包算出后,直接+2*PI*R(人家都是这么做的,就AC了。所以我也这么做)。

    然后就AC。

    程序:

// TASK: 1020 Rope
const
  pi=3.1415926;
type
  point=record
          x,y:real;
        end;
var
  n:longint;
  ans,r:real;
  p:array [0..100] of point;
  s:array [0..100] of longint;
  top:longint;
 function dis(x1,y1,x2,y2:real):real;
 begin
   exit(sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1)));
 end;
 function multi(p1,p2,p0:point):real;
 begin
   exit((p1.x-p0.x)*(p2.y-p0.y)-(p2.x-p0.x)*(p1.y-p0.y));
 end;
 procedure init;
 var
   i,j,k:longint;
   t:point;
  procedure quick(b,e:longint);
  var
    i,j,k:longint;
    x,t:point;
  begin
    i:=b;j:=e;
    x:=p[random(e-b+1)+b];
    while i<=j do
    begin
      while multi(p[i],x,p[1])<0 do inc(i);
      while multi(p[j],x,p[1])>0 do dec(j);
      if i<=j then
      begin
        t:=p[i];
        p[i]:=p[j];
        p[j]:=t;
        inc(i);dec(j);
      end;
    end;
    if b<j then quick(b,j);
    if i<e then quick(i,e);
  end;
 begin
 //  fillchar(p,sizeof(p),0);
   readln(n,r);
   for i:=1 to n do
     readln(p[i].x,p[i].y);
   for i:=n-1 downto 1 do
     if (p[i+1].y<p[i].y)and((p[i+1].y=p[i].y)or(p[i+1].x<p[i].x)) then
     begin
       t:=p[i+1];
       p[i+1]:=p[i];
       p[i]:=t;
     end;
   quick(2,n);
 end;
 procedure calc;
 var
   i,j,k:longint;
 begin
   if n<=1 then
   begin
     ans:=2*pi*r;
   end else begin
     ans:=0;
     fillchar(s,sizeof(s),0);
     top:=2;
     s[1]:=1;s[2]:=2;
     for i:=3 to n do
     begin
       while (top>1)and(multi(p[i],p[s[top]],p[s[top-1]])<0) do dec(top);
       inc(top);
       s[top]:=i;
     end;
     s[top+1]:=1;
 {    writeln(top);
     for i:=1 to top do
     

posted @ 2009-09-08 18:39  为美好世界献上珂学  阅读(92)  评论(0)    收藏  举报