| Describe: |
MP3 Player Because the screen is small, display the song list only a few songs per screen, the user will be able to browse all the songs through the up and down keys. To simplify processing, assume that only 4 songs per screen can be displayed, with the initial position of the cursor being the 1th song.
Now you want to navigate through the list of songs by controlling the cursor movement through the up and down keys, the control logic is as follows:
-
The total number of songs when <=4, do not need to page, just move the cursor position.
When the cursor is on the first song, press the UP key to move to the last song; When the cursor is in the last song, press the Down key to move to the first song.
In other cases the user presses the UP key and the cursor moves to the previous song; The user presses the down key to move the cursor to the next song.
2. When the total number of songs is greater than 4 (take a total of 10 songs for example):
Special page: The screen shows the first page (that is, the 1th - 4 ), the cursor on the first song, the user presses the UP key, the screen to display the last page (that is, the 第7-10首 song), while the cursor on the last song. Similarly, when the screen displays the last page, the cursor is on the last song, the user presses the down key, the screen displays the first page, and the light label moves to the first song.
General page: When the screen is not on the first page, the first song that the cursor displays on the current screen, when the user presses the up key, the screen starts at the top of the current song, and the cursor moves to the previous song. The down key processing is similar for the last song on the current screen of the cursor .
In other cases, do not flip the page, just move the cursor on the line.
|
| Input: |
The first line input parameter is the total number of songs M (0 < m < 255)
The second line is input for user action, D for the down key, and u for up,d and u can be combined arbitrarily. The user's input in the test case is guaranteed to be legitimate and does not need to be verified;
For example:
10
DDDD
Represents 10 songs, the user presses the 4 down key.
|