ENG  RUSTimus Online Judge
Online Judge
Задачи
Авторы
Соревнования
О системе
Часто задаваемые вопросы
Новости сайта
Форум
Ссылки
Архив задач
Отправить на проверку
Состояние проверки
Руководство
Регистрация
Исправить данные
Рейтинг авторов
Текущее соревнование
Расписание
Прошедшие соревнования
Правила
вернуться в форум

Общий форум

Problem 1011
Послано Timus Observer 5 сен 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
Послано Alexander Mavrov 5 сен 2001 21:33
The line "if trunc(...)<> trunc(...)" should be:
"if trunc(...)<ceil(...)"
Re: Problem 1011
Послано Timus Observer 6 сен 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
Послано Mirzayanov Michael 6 сен 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 :(
Послано Algorist 6 сен 2001 17:57
Re: Problem 1011
Послано Algorist 6 сен 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
Послано Timus Observer 6 сен 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
Послано Mirzayanov Michael 7 сен 2001 13:41
:)
Re: Problem 1011
Послано Lin Zi 18 окт 2001 15:10
Thank you,Mirzayanov Michael.how do you find this way to
solve?