Thanks to Clive Fraser for providing this nice sequel to the preceding problem!
You should have solved problem 433 before attempting this problem.
The full problem description is also available in problem 433
.
There are only two minor differences for this advanced version of the problem. The first is that the number N
of islanders is now much larger,
but this will not be greater than one million. The second difference is that you are not required to produce a string of characters (T
and L
)
to indicate Truth Tellers
and Liars
. This would be very long! Instead, you are asked simply to determine how many of the inhabitants are
Truth Tellers
.
Using the small example of problem 433
, where X(0) = 0
and N = 6
, we find that there are 4
Truth Tellers. Only this number is required
as your answer.
Input/Output description: The first and only line of the input data will contain 2
space separated integers.
These are the random seed X(0)
and the problem size N
(the number of inhabitants). You need to determine how many of the inhabitants are
Truth Tellers
. Give your answer as a single integer.
Example 1:
input:
0 6
answer:
4
Example 2:
input:
1234567 887766
answer:
435383