|
|
вернуться в форумHelp! Why my program got WA at test3??? This is my program: var i:longint; a,b:real; procedure init; begin read(a); read(b); a:=a/100; b:=b/100; end; procedure work; begin i:=0; repeat inc(i); until abs(trunc(i*a)-trunc(i*b))>=1; end; procedure print; begin writeln(i); end; begin init; work; print; end. Re: Help! Why my program got WA at test3??? This is my program: var i:longint; a,b:real; procedure init; begin read(a); read(b); a:=a/100; b:=b/100; end; procedure work; begin i:=0; repeat inc(i); until abs(trunc(i*a)-trunc(i*b))>=1;{ see here } (****) end; procedure print; begin writeln(i); end; begin init; work; print; end. Your program have mistake (****) this correct version: repeat inc(i); c := trunc(i*a); d := i*b; if frac(d) = 0 then d := d - 1 Else d := trunc(d); until d > c; I have this program and got AC 0.015s and 373KB :)) Re: Help! Why my program got WA at test3??? What is my mistake? Could you tell me? Re: Help! Why my program got WA at test3??? Try find mistake independent... :))) and prove(****) too Re: Help! Why my program got WA at test3??? Послано harry 25 июл 2005 08:29 Becasue ,if(tranc(i*b)==i*b),in the case,it's possble have mistake! Re: Help! Why my program got WA at test3??? Use SINGLE type - you'll get AC! |
|
|