|
|
вернуться в форумHelp! Why wrong answer? Послано aaa 22 мар 2002 15:35 I've got trouble in 1200. Help me please. Here is my programme: {$n+} const zero=1e-5; var k,c,d,e,f:longint; a,b,max,g:extended; begin assign(input,''); reset(input); assign(output,''); rewrite(output); read(a,b); read(k); max:=-1e10; for c:=0 to k do begin d:=round(b/2); if d<0 then d:=0; if c+d>k then d:=k-c; g:=-sqr(d)+b*d+a*c-sqr(c); if g>max-zero then begin max:=g; e:=c; f:=d; end; end; writeln(max:0:2); writeln(e,' ',f); close(input); close(output); end. Thank you very much! Sorry,I post a wrong programme. Here is the currunt one. Help me! Послано aaa 22 мар 2002 15:45 {$n+} const zero=1e-20; var k,c,d,e,f:longint; a,b,max,g:extended; begin assign(input,''); reset(input); assign(output,''); rewrite(output); read(a,b); read(k); max:=-1e10; for c:=0 to k do begin d:=round(b/2); if d<0 then d:=0; if c+d>k then d:=k-c; g:=-sqr(d)+b*d+a*c-sqr(c); if g>max-zero then begin max:=g; e:=c; f:=d; end; end; writeln(max:0:2); writeln(e,' ',f); close(input); close(output); end. Re: Sorry,I post a wrong programme. Here is the currunt one. Help me! Use trunc, not round. Don't use const zero, only need " if g > max ". I'm sure you'll get AC Thank you for your help! Послано aaa 23 мар 2002 05:45 Could you tell me why use trunc(b/2) instead of other value? I think there maybe some maths reason. Послано aaakkk 19 ноя 2002 08:35 > Use trunc, not round. > Don't use const zero, only need " if g > max ". > I'm sure you'll get AC |
|
|