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:谁做过浙江大学2059?

Posted by busycai at 2006-09-19 15:46:12
In Reply To:谁做过浙江大学2059? Posted by:Lucifer at 2004-07-15 00:59:48
> http://acm.zju.edu.cn/show_problem.php?pid=2059
> 我是在是不知道我的DP哪儿错了.
> 哪位就当作练练读程序的能力帮我看看 ? :-)
> 
> program z2059;
> 
> {$APPTYPE CONSOLE}
> 
> uses
>   SysUtils;
> type thetype=record
>             s:integer;
>             l:longword;
>              end;
> var sum,temp,n:integer;
>     i,i2,now,from:longword;
>     haveone:array [1..2000] of boolean;
>     list:array[1..1000000] of thetype;
> procedure solve;
> begin
>     sum:=0; fillchar(list,sizeof(list),0); fillchar(haveone,sizeof(haveone),false);
>     for i:=1 to n do
>     begin
>     read(temp);
>     list[i].s:=temp;
>     haveone[temp]:=true;
>     sum:=sum+temp;
>     list[i].l:=i;
>     end;
>     if (odd(sum)) or (sum>4000) then begin writeln('Sorry'); exit; end;
>     sum:=sum div 2; from:=0; now:=n;
>     if haveone[sum]=true then begin writeln(sum); exit; end;
>     repeat
>      inc(from);
>      for i2:=list[from].l+1 to n do
>      begin
>         temp:=list[i2].s+list[from].s;
>         if temp=sum then begin writeln(sum); exit; end;
>         if (temp<sum) and (haveone[temp]=false) then
>         begin
>           haveone[temp]:=true;
>           inc(now);
>           list[now].s:=temp;
>           list[now].l:=i2;
> //          if now>10000 then begin writeln('Sorry'); exit; end;
>         end;
>      end;
>     until from>=now;
>     writeln('Sorry');
> end;
> begin
> // assign(input,'e:\acm\zoj\2059.txt');
> //  reset(input);
>   read(n);
>   while n>0 do
>   begin
>     solve;
>     readln;
>     read(n);
>   end;
> //  writeln;
>   { TODO -oUser -cConsole Main : Insert code here }
> end.

和并不是所有的高度相加,可能只是部分。
比如 4 1 2 2 6
输出2而不是SORRY。

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