#P9585. 「MXOI Round 2」酒店
「MXOI Round 2」酒店
Problem Description
Xiao C opened a hotel called CC Hotel.
One day, guests came to CC Hotel. Xiao C needs to arrange all of them on a certain floor of the hotel. Each room can accommodate only one guest.
There are rooms on this floor. All rooms are empty, and these rooms form a ring. That is, for every , room is adjacent to room , and room is adjacent to room , where denotes the remainder when is divided by .
All guests are very picky: they want the rooms adjacent to their own room to be unoccupied. For a guest, if among the rooms adjacent to their room there are occupied rooms, then this guest will gain points of anger.
You need to help Xiao C assign rooms so that the sum of all guests' anger values is minimized, and output the minimum possible sum of anger values of all guests.
Input Format
Two integers .
Output Format
One integer, representing the minimum possible sum of all guests' anger values.
3 5
2
1 4
0
Hint
Sample Explanation #1
For these rooms, one feasible arrangement is: empty, occupied, occupied, empty, occupied.
It can be proven that the minimum possible sum of all guests' anger values is .
Constraints
For of the testdata, , , and it is guaranteed that .
| Test Point ID | Special Property |
|---|---|
| Guaranteed that | |
| Guaranteed that | |
| None |
Translated by ChatGPT 5