NOI2004 小H的小屋

还是纯粹不会啊……到底该怎么办

http://blog.sina.com.cn/s/blog_86942b1401016m3g.html

http://www.cnblogs.com/datam-cy/archive/2012/06/12/NOI2004-hut.html

 1 var n,m,i,ln,rn,lm,rm:longint;
 2     k1,k2,ans,tmp:double;
 3 function area(s,len:longint;k:double):double;
 4  begin
 5  if s=0 then exit(0);
 6  area:=sqr(len div s)*k*(s-len mod s)+sqr(len div s+1)*k*(len mod s);
 7  end;
 8 procedure main;
 9  begin
10  readln(k1,k2,m,n);ans:=maxlongint;
11  lm:=m-n mod m;rm:=n mod m;ln:=n div m;rn:=n div m+1;
12  if rm=0 then ans:=(area(lm,100,k1)+area(lm*ln,100,k2))
13  else
14   for i:=lm*ln to 100-rm*rn do
15    begin
16    tmp:=area(lm,i,k1)+area(rm,100-i,k1)+area(lm*ln,i,k2)+area(rm*rn,100-i,k2);
17    if tmp<ans then ans:=tmp;
18    end;
19  writeln(ans:0:1);
20  end;
21 begin
22  main;
23 end.    
View Code

 

posted @ 2014-06-13 17:44  ZYF-ZYF  Views(260)  Comments(0Edit  收藏  举报