Show all threads Hide all threads Show all messages Hide all messages | Can the amounts of horns and hoofs be 0? | qaztz | 1200. Horns and Hoofs | 27 May 2004 20:08 | 3 | No, you can't. Because K>=1, which means you must produce at least one you are wrong. loook at this. "the total amount of produced goods must not exceed K pieces" it can be 0. :)good luck. | I have tried many times.But I always got WA.Who can help me??? | wangchun | 1200. Horns and Hoofs | 14 May 2004 16:20 | 2 | const max=10000; var a,b,out,temp:real; k,t,al,bl,m,n:integer; s1,s2:array[0..max]of real; begin readln(a,b); readln(k); al:=-1; bl:=-1; for t:=1 to k do begin s1[t]:=a*t-t*t; s2[t]:=b*t-t*t; if (s1[t]<=s1[t-1])and(al=-1) then al:=t-1; if (s2[t]<=s2[t-1])and(bl=-1) then bl:=t-1; if (al<>-1)and(bl<>-1) then break; end; if al+bl<=k then begin out:=s1[al]+s2[bl]; writeln(out:0:2); writeln(al,' ',bl); halt; end; m:=0; n:=0; out:=0; for t:=k-bl to al do begin temp:=s1[t]+s2[k-t]; if temp>out then begin out:=temp; m:=t; n:=k-t; end; end; writeln(out:0:2); writeln(m,' ',n); end. Input: 5434.87 -4567 300 Correct output: 1540461.00 300 0 Your output: 0.00 -1 0 It is wrong. | bruteforce algorithm got WA - ??? :-O | buggzy (Ilya Teterin - USU) | 1200. Horns and Hoofs | 8 Apr 2004 08:44 | 1 | I'm trying all combinations of horns and hoofs amount which sum is not larger than K, calculating its profit and store minimal. The direction of bruteforce should give least amount of horns and hoofs if there are equal profit for several combination. Of course I should use simple calculation instead of bruteforce, but why my stupid program got WA (not time limit) on test 7 ? ;) | Please anyone tell me if in output number of optimal horns(hoofs) can be minus | Vitaliy Surovyi | 1200. Horns and Hoofs | 1 Aug 2003 21:50 | 1 | There are some tests(-4 -7 10) when the answer is minus values. The text of problem is obscure and i don't know what to do. I always have WA. It annoys me a bit! | test | zhangqi | 1200. Horns and Hoofs | 10 May 2003 10:56 | 1 | test zhangqi 10 May 2003 10:56 | Can anyone give me more test pls, it always WA | BoRN | 1200. Horns and Hoofs | 5 Apr 2003 12:18 | 1 | | WHY I GOT "WA"??? Heeeeelp! | Serrg | 1200. Horns and Hoofs | 10 Feb 2003 18:23 | 1 | This is my program: why i got WA var b1,b2,func,cf:real; k,step,a1,a2,i1,i2,t,aa1,aa2:longint; begin step:=10000; a1:=5000; a2:=5000; cf:=0; readln(b1,b2); readln(k); for t:=1 to 4 do begin step:=step div 10; i1:=a1-6*step; while i1<=a1+6*step do begin i2:=a2-6*step; while i2<=a2+6*step do begin if (i1+i2<=k)and(i1>=0)and(i2>=0) then begin func:=i1*b1+i2*b2-i1*i1-i2*i2; if func>cf then begin cf:=func; aa1:=i1; aa2:=i2; end; end; i2:=i2+step; end; i1:=i1+step; end; a1:=aa1; a2:=aa2; end; writeln(cf:0:2); writeln(a1,' ',a2); end. | who can help me? I want more test for this problem ,here is my code(+) | Badd | 1200. Horns and Hoofs | 11 Jan 2003 09:32 | 1 | My algorithm is about Binary Search. #include <stdio.h> int main() { float a,b,m=0; long n,l,l2,lf,rg,c,k; float m1=0,m2=0; FILE* fname=stdin; FILE* fout=stdout; fscanf(fname,"%f%f%ld",&a,&b,&n); for (l=0; l<=n; l++) { if (l>0) if ( (l*l)-(l-1)*(l-1) >= a ) break; lf=1; rg=n-l; c=(lf+rg)/2; k=0; for (; lf<=rg; c=(lf+rg)/2) { if ( (c*c)-(c-1)*(c-1) < b ) { k=c; lf=c+1; } else rg=c-1; } if ( (l*a)+(k*b) - (l*l+k*k) > m ) { m=(l*a)+(k*b) - (l*l+k*k); m1=l; m2=k; } } m=(m1*a)+(m2*b) - (m1*m1+m2*m2); if (m==0) m=0; fprintf(fout,"%.2f\n%.0f %.0f\n",m,m1,m2); fclose(fname); fclose(fout); return 0; } | Help! Why wrong answer? | aaa | 1200. Horns and Hoofs | 19 Nov 2002 08:35 | 5 | 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! {$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. Use trunc, not round. Don't use const zero, only need " if g > max ". I'm sure you'll get AC > Use trunc, not round. > Don't use const zero, only need " if g > max ". > I'm sure you'll get AC | Be careful! A or B may be negative numbers! | train | 1200. Horns and Hoofs | 24 Sep 2002 09:30 | 1 | | I am very sorry that you can proceduce 0 Horn and 0 Hoof! | ECUST kinglions | 1200. Horns and Hoofs | 29 Apr 2002 11:06 | 2 | I am very sorry that you can proceduce 0 Horn and 0 Hoof! sorry,but i don't think so. i've seen an ac problem,and it allows 0 0 | Please help!I don't know why this is wrong. | dynamic(Ying Wang) | 1200. Horns and Hoofs | 22 Apr 2002 17:36 | 1 | I've compared it with an AC program and tested many cases,but still can't find anything wrong.But when I submit,it says WA.Please help me! [code deleted] Edited by moderator 06.12.2019 21:38 | My program got "WA",please help me. | gaozhenwei | 1200. Horns and Hoofs | 7 Apr 2002 14:30 | 3 | [code deleted] Edited by moderator 06.12.2019 21:39 You should change "if (a-sqr(i+1)+sqr(i)<0)and(b-sqr(j+1)+sqr(j)<0) then break;" into "if (a-sqr(i+1)+sqr(i)<=0)and(b-sqr(j+1)+sqr(j)<=0) then break;",and your program will gets AC.
| BTW, what's the answer to this testdata? | turkeys | 1200. Horns and Hoofs | 25 Mar 2002 17:43 | 2 | > 34.20 61.70 > 10000 1244.10 17 31 | I submited my program n times but always got WA, HELP!!! | turkeys | 1200. Horns and Hoofs | 25 Mar 2002 17:23 | 1 | {This is my program} program URAL1200; var a,b,xx,max:real; c,k,x,y:longint; bestx,besty:longint; begin read(a,b,k); max:=0; bestx:=0; besty:=0; for c:=1 to k do begin xx:=(2*c+a-b)/4; if xx<0 then xx:=0; if xx>c then xx:=c; x:=round(xx-0.001); y:=c-x; if a*x+b*y-x*x-y*y>max then begin max:=a*x+b*y-x*x-y*y; bestx:=x; besty:=y; end; end; writeln(max:0:2); writeln(bestx,' ',besty); end. | I cant get AC.. please help.. here is my program | Alyosha Popovich | 1200. Horns and Hoofs | 19 Mar 2002 22:39 | 1 | #include <stdio.h> #include <math.h> long double A, B; int K; int Ba, Bb; long double Best; #define eps 0.001 void solve() { long double p, pb; int a, b; for (a = K, b = 0, pb = 0; a >= 0; a--) { p = (K-a)*(B - K+a); if (p > pb+eps) pb = p, b = K-a; p = a*(A - a) + pb; if (p > Best-eps) Best = p, Ba = a, Bb = b; } } void main() { scanf("%Lf %Lf %d", &A, &B, &K); solve(); printf("%.2Lf\n%d %d\n", Best, Ba, Bb); } | I can't understand, what's wrong with my program. Help, please | Mephistos | 1200. Horns and Hoofs | 19 Mar 2002 17:24 | 1 | type Sum = record Rub, Kop:LongInt; end; var A, B:Sum; K:LongInt; procedure Inp; var _A, _B:Extended; begin Read(_A, _B); A.Rub:=Round(_A*100) div 100; A.Kop:=Round(_A*100) mod 100; B.Rub:=Round(_B*100) div 100; B.Kop:=Round(_B*100) mod 100; Read(K); end; procedure Profit(Coeff:Sum; Count:LongInt; var P:Sum); begin P.Rub:=Count*(Coeff.Rub-Count)+(Count*Coeff.Kop) div 100; P.Kop:=(Count*Coeff.Kop) mod 100; end; function FindMax(V:Sum):LongInt; var P, Bp:sum; I, Max:LongInt; begin FillChar(Bp, Sizeof(Bp), 0); for I:=0 to K do begin Profit(V, I, P); if (P.Rub>Bp.Rub) or ((P.Rub=Bp.Rub) and (P.Kop>Bp.Kop)) then begin Max:=I; BP:=P; end; end; FindMax:=Max; end; var BX, BY:LongInt; BP:Sum; procedure Run; var Xmax, Ymax:LongInt; X, Y:LongInt; P, Py:Sum; I, J:LongInt; begin FillChar(Bp, Sizeof(BP), 0); Xmax:=FindMax(A); Ymax:=FindMax(B); for I:=0 to K do begin X:=I; if (X>XMax) then X:=XMax; Y:=K-I; if (Y>YMax) then Y:=YMax; P.Rub:=0; P.Kop:=0; Profit(A, X, P); Profit(B, Y, Py); P.Rub:=P.Rub+Py.Rub+(P.Kop+Py.Kop) div 100; P.Kop:=(P.Kop+Py.Kop) mod 100; if (P.Rub>BP.Rub) or ((P.Rub=Bp.Rub) and (P.Kop>Bp.Kop)) then begin BP:=P; BX:=X; BY:=Y; end; end; end; procedure Out; begin Write(Bp.Rub, '.'); if (BP.Kop<10) then Write(0, BP.Kop mod 100) else if (BP.Kop mod 100=0) then Write('00') else Write(BP.Kop mod 100); WriteLn; WriteLn(Bx, ' ', BY); end; begin { Assign(Input, 'Input.txt'); Reset(Input);} Inp; Run; Out; { Close(Input);} end. |
|
|