#P9177. [COCI 2022/2023 #5] Kalendar

[COCI 2022/2023 #5] Kalendar

Problem Description

Magdalena likes calendars, and she makes her own calendar for each month.

Each day of the month is represented using exactly three characters:

  • If the day number has one digit, it is written as ..X. For example, the number 77 is written as ..7.
  • If the day number has two digits, it is written as .XY. For example, the number 1717 is written as .17.

Each row of the calendar represents one week, and each week has 77 days. If a week does not contain all 77 days (because the month may not start on Monday, or may not end on Sunday), then the missing days are shown as ....

Magdalena also wants her calendar to look nice. She will decorate it in the following way: she will fill the top and bottom with - (ASCII 45), the left and right sides with | (ASCII 124), and the four corners with + (ASCII 43).

Your task is to determine the format of Magdalena's calendar if it has nn days and the first day of the month is the xx-th day of the week. For example, if x=1x=1, the month starts on Monday; if x=5x=5, it starts on Friday.

We assume that the first day of the week is Monday.

Input Format

One line containing integers nn and x(1n99,1x7)x(1\leq n\leq 99,1\leq x\leq 7), representing the number of days in the month and the weekday on which the month starts.

Output Format

Output what Magdalena's calendar looks like.

31 3
+---------------------+
|........1..2..3..4..5|
|..6..7..8..9.10.11.12|
|.13.14.15.16.17.18.19|
|.20.21.22.23.24.25.26|
|.27.28.29.30.31......|
+---------------------+
1 5
+---------------------+
|..............1......|
+---------------------+
28 7
+---------------------+
|....................1|
|..2..3..4..5..6..7..8|
|..9.10.11.12.13.14.15|
|.16.17.18.19.20.21.22|
|.23.24.25.26.27.28...|
+---------------------+

Hint

Subtask ptspts Constraints
00 This is the sample.
11 77 n+x8n+x\leq 8
22 1919 x=1x=1
33 2424 None.

Translated by ChatGPT 5