| Gene Mutation |
|---|
Another threatening feature of 'supervirus' is that the virus is very infectious.
It can be transmitted by direct contact of the saliva of the infected person,
so if he talks to someone, the virus is easily spreaded to that person.
Fortunately, Dr. Jones has invented a drug that can be injected to the infected people to cure them. Since the drug targets at the deoxyribonucleic acid (DNA in short) molecule inside the virus, the efficacy of the drug will be reduced if the 'supervirus' is mutated.
Dr. Jones discover that the gene of a 'supervirus' can be represented by
a cycle of
distinct positive integers, and they are from
to
.
For example, when
= 5, the gene of the 'supervirus' is shown in figure 1.
Before mutation, exactly one of the
bonds in
the gene must be broken down first.
Then, it will mutate for several times by swapping several
pairs of adjacent numbers, and then form the broken bond again.
For example, after 2 mutations, the gene may become (see figure 2):
Dr. Jones cannot predict which bond will be broken,
but he has confirmed that each 'supervirus' can break down one
bond and form that bond again for at most once.
The current drug can be slightly modified to treat different
mutated viruses, but it will have no therapeutic effect anymore
when the gene becomes a cycle of
in clockwise direction (see figure 3).
He calls this an 'ultravirus'.
In order to estimate the time left for inventing new drugs before the mutation of 'supervirus' into 'ultravirus', he asks you to find the minimum number of mutations needed.
5 1 2 4 5 3
2
5 4 5 3 1 2
2