English · Original
Chinese · Translation
Formal · Original
You are given names of two days of the week.
Please, determine whether it is possible that during some **non-leap year** the first day of some month was equal to the first day of the week you are given, while the first day of **the next month** was equal to the second day of the week you are given. **Both months should belong to one year**.
In this problem, we consider the Gregorian calendar to be used. The number of months in this calendar is equal to 12. The number of days in months during any non-leap year is: 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31.
Names of the days of the week are given with lowercase English letters: "_monday_", "_tuesday_", "_wednesday_", "_thursday_", "_friday_", "_saturday_", "_sunday_".
## Input
The input consists of two lines, each of them containing the name of exactly one day of the week. It's guaranteed that each string in the input is from the set "_monday_", "_tuesday_", "_wednesday_", "_thursday_", "_friday_", "_saturday_", "_sunday_".
## Output
Print "_YES_" (without quotes) if such situation is possible during some non-leap year. Otherwise, print "_NO_" (without quotes).
[samples]
## Note
In the second sample, one can consider February 1 and March 1 of year 2015. Both these days were Sundays.
In the third sample, one can consider July 1 and August 1 of year 2017. First of these two days is Saturday, while the second one is Tuesday.
给你两个星期几的名称。
请判断是否存在某一年(非闰年),使得某个月的第一天等于你给出的第一个星期几,而下一个月的第一天等于你给出的第二个星期几。*这两个月份必须属于同一年*。
本题中,我们使用格里高利历。该历法中的月份数为 12。在任何非闰年中,各月的天数为:#cf_span[31], #cf_span[28], #cf_span[31], #cf_span[30], #cf_span[31], #cf_span[30], #cf_span[31], #cf_span[31], #cf_span[30], #cf_span[31], #cf_span[30], #cf_span[31]。
星期几的名称用小写英文单词表示:"_monday_"、"_tuesday_"、"_wednesday_"、"_thursday_"、"_friday_"、"_saturday_"、"_sunday_"。
输入由两行组成,每行包含一个星期几的名称。保证输入中的每个字符串均来自集合 "_monday_"、"_tuesday_"、"_wednesday_"、"_thursday_"、"_friday_"、"_saturday_"、"_sunday_"。
如果在某一年(非闰年)中存在上述情况,请输出 "_YES_"(不含引号);否则,输出 "_NO_"(不含引号)。
在第二个样例中,可以考虑 2015 年的 2 月 1 日和 3 月 1 日。这两天都是星期日。
在第三个样例中,可以考虑 2017 年的 7 月 1 日和 8 月 1 日。前者是星期六,后者是星期二。
## Input
输入由两行组成,每行包含一个星期几的名称。保证输入中的每个字符串均来自集合 "_monday_"、"_tuesday_"、"_wednesday_"、"_thursday_"、"_friday_"、"_saturday_"、"_sunday_"。
## Output
如果在某一年(非闰年)中存在上述情况,请输出 "_YES_"(不含引号);否则,输出 "_NO_"(不含引号)。
[samples]
## Note
在第二个样例中,可以考虑 2015 年的 2 月 1 日和 3 月 1 日。这两天都是星期日。
在第三个样例中,可以考虑 2017 年的 7 月 1 日和 8 月 1 日。前者是星期六,后者是星期二。
**Definitions**
Let $ D = \{ \text{monday}, \text{tuesday}, \text{wednesday}, \text{thursday}, \text{friday}, \text{saturday}, \text{sunday} \} $ be the set of days of the week, indexed cyclically by $ \mathbb{Z}_7 $, where:
- $ \text{monday} \mapsto 0 $,
- $ \text{tuesday} \mapsto 1 $,
- $ \text{wednesday} \mapsto 2 $,
- $ \text{thursday} \mapsto 3 $,
- $ \text{friday} \mapsto 4 $,
- $ \text{saturday} \mapsto 5 $,
- $ \text{sunday} \mapsto 6 $.
Let $ L = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] $ be the sequence of days in each month of a non-leap year.
Let $ d_1, d_2 \in D $ be the two input days of the week.
**Constraints**
- $ d_1, d_2 \in D $.
**Objective**
Determine whether there exists $ i \in \{0, 1, \dots, 11\} $ such that:
$$
(d_1 + \text{days in month } i) \bmod 7 = d_2
$$
Equivalently, define $ \Delta_i = L[i] \bmod 7 $. Then check:
$$
\exists\, i \in \{0, \dots, 11\} \text{ such that } (d_1 + \Delta_i) \bmod 7 = d_2
$$
API Response (JSON)
{
"problem": {
"name": "A. Checking the Calendar",
"description": {
"content": "You are given names of two days of the week. Please, determine whether it is possible that during some **non-leap year** the first day of some month was equal to the first day of the week you are giv",
"description_type": "Markdown"
},
"platform": "Codeforces",
"limit": {
"time_limit": 1000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "CF724A"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given names of two days of the week.\n\nPlease, determine whether it is possible that during some **non-leap year** the first day of some month was equal to the first day of the week you are giv...",
"is_translate": false,
"language": "English"
},
{
"statement_type": "Markdown",
"content": "给你两个星期几的名称。\n\n请判断是否存在某一年(非闰年),使得某个月的第一天等于你给出的第一个星期几,而下一个月的第一天等于你给出的第二个星期几。*这两个月份必须属于同一年*。\n\n本题中,我们使用格里高利历。该历法中的月份数为 12。在任何非闰年中,各月的天数为:#cf_span[31], #cf_span[28], #cf_span[31], #cf_span[30], #cf_span[31]...",
"is_translate": true,
"language": "Chinese"
},
{
"statement_type": "Markdown",
"content": "**Definitions** \nLet $ D = \\{ \\text{monday}, \\text{tuesday}, \\text{wednesday}, \\text{thursday}, \\text{friday}, \\text{saturday}, \\text{sunday} \\} $ be the set of days of the week, indexed cyclically b...",
"is_translate": false,
"language": "Formal"
}
]
}