In input 4, isn't the answer 5? Because Peter will be the sixth person and he will get a prime number ticket which is 29. But the given answer is -1. In my program, everything is true except for the 4th test.
Khayyam7 keep in mind that Vanja and Peter are also included in , meaning Peter can only advance ticket number by before taking a ticket himself.
In the example, the starting ticket number is 23 (one taken by Vanja), Peter can let up to 4 passengers to take tickets before him, reaching number 27, then he will take #28.
user117860 in the second test the numbers in the input file were separated by two spaces and your solution couldn't handle it correctly. I have corrected the test.
Тест номер 4: изначальный билет номер 23, количество пассажиров 6. Нужно пропустить 5 пассажиров, чтобы купить простой билет с номером 29. У вас указано, что в этом случае правильный ответ -1, то есть невозможно. Код проходит на 90%, кроме этого случая. Не пойму, у меня ошибка или на сайте ?