As multiprocessor computers become more widespread in our lives,
it becomes more and more important to write parallel programs
that can solve tasks using several processors.
However, designing parallel programs is difficult for
many reasons. Let us consider two of them. First, some
amount of work cannot be parallelized and must therefore
be executed on a single processor. Besides that, when increasing the number
of processors, the amount of work needed for synchronization increases.
We will assume that there is one special processor that controls the
execution and executes the unparallelizable part, and that
the increase in time due to synchronization is linear in the number of processors.
You are given ints t0, tp, and ts.
t0 is the number of seconds needed for the execution of the
unparallelizable part. tp is the number of seconds needed
for execution of the parallelizable part on a single processor.
ts is the number of seconds added to the synchronization time
for each additional processor.
The time needed to execute the whole task on one processor is t0+tp.
The time needed to execute the whole task on n > 1 processors is
max(t0, tp/(n-1) + ts*(n-1)). Here tp/(n-1) is a floating point number.
Return the number of processors needed to execute the task in minimal time.
If there are multiple solutions, return the smallest among them.
|