P27417 [AtCoder] Calendar 2
提高-
题目描述

Problem Description

Input Format

The input is given in the following format:

$ n $ $ m $ $ q $ $ a_1 $ $ a_2 $ ... $ a_q $

Output Format

Output the number of connected parts in one line.

Sample Input and Output

Sample Input #1

7 7 3
1 3 5

Sample Output #1

4

Sample Input #2

10 14 8
5 6 7 8 9 10 11 12

Sample Output #2

10

Notes/Hints

Constraints

  • $ n $ ≦ $ 10^{12} $
  • $ 7n $ is divisible by $ m $.
  • 1 ≦ $ q $ ≦ $ m $ ≦ $ 10^5 $
  • $ 0 $ ≦ $ a_1 $ $ a_2 $ ... $ a_q $

Scoring

Subtask 1 [$ 100 $ points]

  • $ n $ ≦ $ 100000 $.

Subtask 2 [$ 90 $ points]

  • $ m $ is a multiple of $ 7 $.
  • $ a_{i + 1} - a_i = 1 $.

Subtask 3 [$ 200 $ points]

  • $ m $ is a multiple of $ 7 $.

Subtask 4 [$ 110 $ points]

  • No additional constraints.

Sample Explanation 1

The calendar looks like this. Therefore, the number of connected parts is $ 4 $.

Sample Explanation 2

The calendar looks like this. Therefore, the number of connected parts is $ 10 $ (corrected on 2020/8/08).

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
7 7 3 1 3 5
样例输出
4