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

Help! Why my program got WA at test3???
Posted by Tang RZ 2 Jun 2004 10:28
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???
Posted by marina_ufa 2 Jun 2004 13:12
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???
Posted by Tang RZ 3 Jun 2004 10:05
What is my mistake? Could you tell me?
Re: Help! Why my program got WA at test3???
Posted by marina_ufa 3 Jun 2004 14:50
Try find mistake independent... :))) and prove(****) too
Re: Help! Why my program got WA at test3???
Posted by harry 25 Jul 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???
Posted by Gleb Grenkin 15 Aug 2005 12:25
Use SINGLE type - you'll get AC!