|
|
вернуться в форум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. 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 :)) What is my mistake? Could you tell me? Try find mistake independent... :))) and prove(****) too Becasue ,if(tranc(i*b)==i*b),in the case,it's possble have mistake! Use SINGLE type - you'll get AC! |
|
|