Problem D
Prince and Princess
On an
![\includegraphics[width=0.35\textwidth ]{prince1}](/problems/princeandprincess/file/statement/en/img-0001.jpg)
The Prince stands in square
The Princess does essentially the same thing – stands in
square
Figure 2 below shows a
![\includegraphics[width=0.55\textwidth ]{prince2}](/problems/princeandprincess/file/statement/en/img-0002.jpg)
The Prince moves along the sequence:
The King, their father, has just come. “Why move separately? You are brother and sister!”, said the King, “Ignore some jumps and make sure that you’re always together.”
For example, if the Prince ignores his 2:nd, 3:rd, and 6:th
jump, he’ll follow the route:
Input
The first line of the input contains a single integer
Output
For each test case, print the case number and the length of longest route they can move together. Look at the output for sample input for details.
Sample Input 1 | Sample Output 1 |
---|---|
1 3 6 7 1 7 5 4 8 3 9 1 4 3 5 6 2 8 9 |
Case 1: 4 |