atcoder#ABC268C. [ABC268C] Chinese Restaurant
[ABC268C] Chinese Restaurant
Score : points
Problem Statement
Person , Person , , and Person are sitting around a turntable in their counterclockwise order, evenly spaced. Dish is in front of Person on the table. You may perform the following operation or more times:
- Rotate the turntable by one -th of a counterclockwise turn. As a result, the dish that was in front of Person right before the rotation is now in front of Person .
When you are finished, Person is happy if Dish is in front of Person , Person , or Person . Find the maximum possible number of happy people.
What is $a \bmod m$?
For an integer a and a positive integer m, a \bmod m denotes the integer x between 0 and (m-1) (inclusive) such that (a-x) is a multiple of m. (It can be proved that such x is unique.)Constraints
- if .
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4
1 2 0 3
4
The figure below shows the table after one operation.
Here, there are four happy people:
- Person is happy because Dish is in front of Person ;
- Person is happy because Dish is in front of Person ;
- Person is happy because Dish is in front of Person ;
- Person is happy because Dish is in front of Person .
There cannot be five or more happy people, so the answer is .
3
0 1 2
3
10
3 9 6 1 7 2 8 0 5 4
5