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 1607. Taxi

Help me, please
Posted by Rez 21 Aug 2008 03:52
CODE:
var a,b,c,d:word;
begin
{$IFNDEF ONLINE_JUDGE}
   assign(input, 'input.txt');
   reset(input);
   assign(output, 'output.txt');
   rewrite(output);
{$ENDIF}
read(a,b,c,d);
while ((c>=(a+b)) and (a<=(c-d))) do begin
a:=a+b;
c:=c-d;
end;
If a<=c then
writeln(c);
If c<a then writeln(a);
{$IFNDEF ONLINE_JUDGE}
   close(input);
   close(output);
{$ENDIF}
end.

Wrong answer    2

for exanmple try test
1000 2 2000 3
answer is 1400
1 2 12 3
6
100 100 150 20
150
2 1 1 1
2
150 50 1000 100
450
What then error?
Re: Help me, please
Posted by Shahriar Nirjon 17 Sep 2008 10:43
I see an error-

Like, you are saying- "if a<=c then writeln(c)" I think it is wrong. If a+b<=c then answer may be (a+b).

for example, a = 10, b = 7, c = 20, d = 15

Now, the answer is 17.