A. Petr and a calendar

Codeforces
IDCF760A
Time2000ms
Memory256MB
Difficulty
implementationmath
English · Original
Chinese · Translation
Formal · Original
Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to weekdays, and cells contain dates. For example, a calendar for January 2017 should look like on the picture: <center>![image](https://espresso.codeforces.com/489b3cfc33d183f898ec6c5dbd5bfc38dffc297c.png)</center>Petr wants to know how many columns his table should have given the month and the weekday of the first date of that month? Assume that the year is non-leap. ## Input The only line contain two integers _m_ and _d_ (1 ≤ _m_ ≤ 12, 1 ≤ _d_ ≤ 7) — the number of month (January is the first month, December is the twelfth) and the weekday of the first date of this month (1 is Monday, 7 is Sunday). ## Output Print single integer: the number of columns the table should have. [samples] ## Note The first example corresponds to the January 2017 shown on the picture in the statements. In the second example 1\-st January is Monday, so the whole month fits into 5 columns. In the third example 1\-st November is Saturday and 5 columns is enough.
Petr 想要为当前月份制作一个日历。为此,他画了一个表格,其中列对应周(一周为从周一到周日的连续七天),行对应星期几,单元格包含日期。例如,2017年1月的日历应如下图所示: Petr 想要知道,给定月份和该月第一天的星期几,他的表格应该有多少列?假设该年为平年。 仅一行包含两个整数 $m$ 和 $d$($1 ≤ m ≤ 12$,$1 ≤ d ≤ 7$)—— 月份编号(一月为第一个月,十二月为第十二个月)和该月第一天的星期几($1$ 表示周一,$7$ 表示周日)。 输出一个整数:表格应具有的列数。 第一个示例对应于题面图中所示的2017年1月。 在第二个示例中,1月1日是星期一,因此整个月份只需 $5$ 列即可容纳。 在第三个示例中,11月1日是星期六,$5$ 列已足够。 ## Input 仅一行包含两个整数 $m$ 和 $d$($1 ≤ m ≤ 12$,$1 ≤ d ≤ 7$)—— 月份编号(一月为第一个月,十二月为第十二个月)和该月第一天的星期几($1$ 表示周一,$7$ 表示周日)。 ## Output 输出一个整数:表格应具有的列数。 [samples] ## Note 第一个示例对应于题面图中所示的2017年1月。在第二个示例中,1月1日是星期一,因此整个月份只需 $5$ 列即可容纳。在第三个示例中,11月1日是星期六,$5$ 列已足够。
**Definitions** Let $ m \in \{1, \dots, 12\} $ be the month number. Let $ d \in \{1, \dots, 7\} $ be the weekday of the first day of the month ($1 =$ Monday, $7 =$ Sunday). Let $ N(m) $ be the number of days in month $ m $, defined as: $$ N(m) = \begin{cases} 31 & \text{if } m \in \{1, 3, 5, 7, 8, 10, 12\} \\ 30 & \text{if } m \in \{4, 6, 9, 11\} \\ 28 & \text{if } m = 2 \end{cases} $$ **Constraints** $ 1 \leq m \leq 12 $, $ 1 \leq d \leq 7 $ **Objective** Compute the number of columns (weeks) required to display the calendar: $$ \left\lceil \frac{N(m) + d - 1}{7} \right\rceil $$
Samples
Input #1
1 7
Output #1
6
Input #2
1 1
Output #2
5
Input #3
11 6
Output #3
5
API Response (JSON)
{
  "problem": {
    "name": "A. Petr and a calendar",
    "description": {
      "content": "Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to week",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF760A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Petr wants to make a calendar for current month. For this purpose he draws a table in which columns correspond to weeks (a week is seven consequent days from Monday to Sunday), rows correspond to week...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "Petr 想要为当前月份制作一个日历。为此,他画了一个表格,其中列对应周(一周为从周一到周日的连续七天),行对应星期几,单元格包含日期。例如,2017年1月的日历应如下图所示:\n\nPetr 想要知道,给定月份和该月第一天的星期几,他的表格应该有多少列?假设该年为平年。\n\n仅一行包含两个整数 $m$ 和 $d$($1 ≤ m ≤ 12$,$1 ≤ d ≤ 7$)—— 月份编号(一月为第一个月,十二月...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ m \\in \\{1, \\dots, 12\\} $ be the month number.  \nLet $ d \\in \\{1, \\dots, 7\\} $ be the weekday of the first day of the month ($1 =$ Monday, $7 =$ Sunday).  \nLet $ N(m) $ be the n...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments