#abc268c. C - Chinese Restaurant
C - Chinese Restaurant
Score : points
问题描述
设有号、号、及号共个人,他们按照逆时针顺序均匀地围坐在一个转盘周围。桌上碟子位于第号人面前。
你可以执行以下操作零次或多次:
- 将转盘逆时针旋转圈。这样一来,在旋转前位于第号人面前的碟子,现在会位于第号人面前。
操作结束后,如果碟子位于第号人、第号人或第号人面前,则认为第号人是满意的。
求最多能使多少人感到满意。
什么是?对于整数和正整数,表示在到(包含两端)之间的一个整数,满足是的倍数。(可以证明这样的是唯一的。)
以上为通义千问 qwen-max 翻译,仅供参考。
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 ? For an integer and a positive integer , denotes the integer between and (inclusive) such that is a multiple of . (It can be proved that such 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.
Sample Input 1
4
1 2 0 3
Sample Output 1
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 .
Sample Input 2
3
0 1 2
Sample Output 2
3
Sample Input 3
10
3 9 6 1 7 2 8 0 5 4
Sample Output 3
5
update @ 2024/3/10 11:18:07