|
|
back to boardDiscussion of Problem 1607. TaxiЧто нужно поправить,чтобы эта программа реализовывала тест '60 100 300 1'?вообще она ломается на 10 тесте при сдаче, но после того как я посмотрела обсуждения и прогнала её по найденным тестам поняла что не могу реализовать только один выше сказанный ответ кстати (как я думаю) 298. вот тесты на которых пробовала. к стати я очень невнимательная, поэтому сильно на меня не ругаться ))) 150 50 1000 100 ответ - 450 1 4 2 2 ответ - 2 1 3 5 2 ответ - 4 2 1 1 1 ответ - 2 1 3 4 3 ответ - 4 1000 2 2000 3 ответ - 140 11 1 10 2 ответ - 11 4 3 6 1 ответ - 6 1 2 12 3 ответ - 6 var a,b,c,d:integer; begin read(a,b,c,d); if a>c then write(a) else begin while a<>c do begin a:=a+b; if (a>c-d)and(c>a) then c:=a else if a+b>c then a:=c else if a=c then break else c:=c-d; end; write(c); end; end. Заранее спасибо)♥_♥ Edited by author 28.12.2017 21:55 Edited by author 28.12.2017 21:56 Let's take a look at this simple test: 32 36 80 4 The process goes like this: 32 -> 80 -> 32+36=68 -> 80-4=76 -> 68+36=104>76, so the end result is 76. Now, let's take a look at how you handle it. a=32 b=36 c=80 d=4 a:=a+b; -> a = 68 now if (a>c-d)and(c>a) then c:=a -> 68>80-4 is false, so this doesn't trigger else if a+b>c then a:=c -> 68+36=104>80, a becomes 80 here. then, while a<>c is checked again, a = c = 80 at this point, so it jumps to write(c). However, answer is 76 and not 80. Hope this helps you to figure out the problem! 150 50 1000 100 Why in this test answer is 450 (not 500) ? |
|
|