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 proverbs at 2012-07-20 22:54:18 on Problem 1853
In Reply To:我过了,太坎坷了!提供题解和代码: Posted by:lydliyudong at 2011-04-26 16:58:02
> 题解:http://hi.baidu.com/lydrainbowcat/blog/item/fbe8db6687c3b332aa184c65.html
> 
> var
>  f:array[0..30000]of boolean;
>  d:array[0..30000]of longint;
>  a:array[0..100]of longint;
>  b:array[0..100]of double;
>  sum:double;
>  n,i,j:longint; 
> procedure print(x:longint);
>  begin
>   if x=0 then exit;
>   print(x-a[d[x]]);
>   if x<>i then write(d[x],' ') else writeln(d[x]);
>  end;
> begin
>  repeat
>   readln(n);
>   if n=0 then exit;
>   sum:=0;
>   for i:=1 to n do
>    begin
>     readln(b[i]);
>     sum:=sum+b[i];
>    end;
>   for i:=1 to n do
>    a[i]:=trunc((b[i]/sum)*20000);
>   fillchar(f,sizeof(f),0);
>   f[0]:=true;
>   for i:=1 to n do
>    for j:=10000 downto 0 do
>     if f[j] and not f[j+a[i]] then
>      begin
>       f[j+a[i]]:=true;
>       d[j+a[i]]:=i;
>      end;
>   i:=10000;
>   while not f[i] do dec(i);
>   print(i);
>  until false;
> end.
> 
OTZZZZZZZZZZZZZZZZZ

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