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

Discussion of Problem 1011. Conductors

why my program is wrong ?!
Posted by behrang 13 Mar 2003 00:26
program conductor;
var
   q,p,p1,q1:real;
   i:integer;
begin
     readln(p,q);
     for i:=1 to 11000 do
         begin
              p1:=trunc((i*p)/100);
              q1:=trunc((i*q)/100);
              if (q1-p1)>0 then
                 begin
                      writeln(i);
                      exit;
                 end;
         end;
end.
I found Dear BEHRANG.
Posted by Locomotive 13 Mar 2003 11:55
Hi dear Behrang
at first welcome to Timus Iranian Programmers!
and then for getting Ac on 1011:

Insert this line at point I refered:

---> if frac(q1)=0 then q1:=q1-1
     else q1:=trunc(q1);

and delete trunc on

---> q1=trunc((i*q)/100);

so...

~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~
> program conductor;
> var
>    q,p,p1,q1:real;
>    i:integer;
> begin
>      readln(p,q);
>      for i:=1 to 11000 do
>          begin
>               p1:=trunc((i*p)/100);
>               q1:=trunc((i*q)/100);
(* insert my hint here (if line) so you will got AC *)
>               if (q1-p1)>0 then
>                  begin
>                       writeln(i);
>                       exit;
>                  end;
>          end;
> end.
~~~~~~~~~~~~~
will be :
 var
    q,p,p1,q1:real;
    i:integer;
 begin
      readln(p,q);
      for i:=1 to 11000 do
          begin
               p1:=trunc((i*p)/100);
               q1:=(i*q)/100;
               if frac(q1)=0 then q1:=q1-1
                 else q1:=trunc(q1);
               if (q1-p1)>0 then
                  begin
                       writeln(i);
                       exit;
                  end;
          end;
 end.



Best
Aidin_n7@hotmail.com