ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Common Board

Problem 1011
Posted by Timus Observer 5 Sep 2001 21:28
Can someone help me on this:
---
I keep getting Wrong Answer, but I can pass the given test
case:
program pr1011_conductors;
var sol : integer;
    pct1, pct2 : real;
    found : boolean;
begin
found:=false;
sol:=0;
read(pct1,pct2);
while not found do
begin
  inc(sol);
  if trunc(sol*pct1/100) <> trunc(sol*pct2/100) then
found:=true;
end;
writeln(sol);
end.
Re: Problem 1011
Posted by Alexander Mavrov 5 Sep 2001 21:33
The line "if trunc(...)<> trunc(...)" should be:
"if trunc(...)<ceil(...)"
Re: Problem 1011
Posted by Timus Observer 6 Sep 2001 08:06
> The line "if trunc(...)<> trunc(...)" should be:
> "if trunc(...)<ceil(...)"
I have tried but still got WA. I used 'floor' instead
of 'ceil', since ceil could not pass the problem test case.

Probably this problem can be answered only using C, not
Pascal :((
---
program pr1011_conductors;
uses math;
var sol : integer;
    pct1, pct2 : real;
    found : boolean;
begin
found:=false;
sol:=0;
read(pct1,pct2);
while not found do
begin
  inc(sol);
  if (trunc(sol*pct1/100) < floor(sol*pct2/100)) then
found:=true;
end;
writeln(sol);
end.
Re: Problem 1011
Posted by Mirzayanov Michael 6 Sep 2001 10:50
Piece of solution:

eps=1E-7;
"
  procedure Solve;
    var
      i,j:int;
      lo,hi:real;
  begin
    for i:=1 to 50000 do begin
      lo:=i*p;
      hi:=i*q;
      lo:=lo+eps;
      hi:=hi-eps;
      if trunc(lo)<trunc(hi) then begin
        ans:=i;
        exit;
      end;
    end;
  end;
"
  procedure ReadData;
    var
      i,j:int;
  begin
    read(p);
    read(q);
    p:=p/100;
    q:=q/100;
  end;
It can't be submitted ina C as well :(
Posted by Algorist 6 Sep 2001 17:57
Re: Problem 1011
Posted by Algorist 6 Sep 2001 18:04
I got accepted when I used this piece. You are great! But
one question - how is that constant eps 1E-7 computed?
Re: Problem 1011
Posted by Timus Observer 6 Sep 2001 18:30
> I got accepted when I used this piece. You are great! But
> one question - how is that constant eps 1E-7 computed?
I got accepted too using this one, I think epsilon is small
number for correction of real type. What I do not
understand why it does not work if we use :
if trunc(...) - trunc(....) < eps then ...
why we use hi-eps and lo+eps
Magic
Posted by Mirzayanov Michael 7 Sep 2001 13:41
:)
Re: Problem 1011
Posted by Lin Zi 18 Oct 2001 15:10
Thank you,Mirzayanov Michael.how do you find this way to
solve?