atcoder#ARC080D. [ARC080F] Prime Flip
[ARC080F] Prime Flip
Score : points
Problem Statement
There are infinitely many cards, numbered , , , Initially, Cards , , , are face up, and the others are face down.
Snuke can perform the following operation repeatedly:
- Select a prime greater than or equal to . Then, select consecutive cards and flip all of them.
Snuke's objective is to have all the cards face down. Find the minimum number of operations required to achieve the objective.
Constraints
Input
Input is given from Standard Input in the following format:
Output
Print the minimum number of operations required to achieve the objective.
2
4 5
2
Below is one way to achieve the objective in two operations:
- Select and flip Cards , , , and .
- Select and flip Cards , and .
9
1 2 3 4 5 6 7 8 9
3
Below is one way to achieve the objective in three operations:
- Select and flip Cards , and .
- Select and flip Cards , and .
- Select and flip Cards , and .
2
1 10000000
4