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

wa#4
Posted by koyot 25 May 2008 20:39
here's my text:

program Project2;
var a,b,c,d:longint;
begin
 readln (a,b,c,d);

 while c>a do begin
a:=a+b;
c:=c-d;
  end;
if c=a+b then
   writeln (c)
else writeln (a);

end.


what's the problem??? help me please
Re: wa#4
Posted by ACM.Krupko_Victor[Ivanovo SPU] 25 May 2008 22:03
4 3 6 1
correct answer: 6
Re: wa#4
Posted by koyot 26 May 2008 14:16
thanks but now wa is #6 can't understand what ellse I've missed.
Re: wa#4
Posted by ACM.Krupko_Victor[Ivanovo SPU] 26 May 2008 16:03
give me your code
Re: wa#4
Posted by koyot 26 May 2008 17:07
program Project2;
var a,b,c,d:longint;
begin
 readln (a,b,c,d);
if c<a+b then
writeln (c)
else begin
 while c>a do begin
a:=a+b;
c:=c-d;
  end;
writeln (a);
end;

end.
Re: wa#4
Posted by rohit 26 May 2008 18:05
If a>c in the beginning then answer is a not c.
Also check whether a>c after adding b each time.
Re: wa#4
Posted by adilchib 16 Mar 2009 13:48
correct answer is 7.
Re: wa#4
Posted by Neo_OKTL 16 Mar 2009 14:15
4 3 6 1
correct answer is 7
Re: wa#4
Posted by Kiril Kafadarov - new 24 Apr 2009 23:59
WHY???

Petr offers 4
Taxi says 6
Petr won't increase because 4+3>6 => the answer is 7
Re: wa#4
Posted by Dj_Denis 9 Nov 2009 14:55
Here is correct code

var a,b,c,d:integer;
begin
Readln(a,b,c,d);
While a<=c do begin
a:=a+b;
if a>c then a:=c;
c:=c-d;
end;
Write(a);
end.

Edited by author 09.11.2009 14:56
Re: wa#4
Posted by jambas92 18 Sep 2011 17:24
correct answer is 6! Read the task carefully!!
Re: wa#4
Posted by mr.sanatbek_94 22 Mar 2015 16:59
No correct answer must be 6.
Because, Peter offer: 4 but when you add 3 it will be 7>6 in this case a must be equal 6. Beacause driver satisfy 6 money.
In this case put this condition to your iterator:
if(a>c) a=c;