#P9690. [GDCPC2023] Programming Contest

[GDCPC2023] Programming Contest

题目描述

Guangdong Province is one of the earliest province in China which holds its own provincial collegiate programming contest. Sun Yat-sen University hosted the first Guangdong Collegiate Programming Contest in year 20032003. After that, other universities in Guangdong, such as South China Agricultural University, South China University of Technology and South China Normal University, also hosted the contest. The contest is held once a year except for year 20202020 due to the epidemic. In year 20232023, Shenzhen Technology University will host the twentieth Guangdong Collegiate Programming Contest. We are looking forward to seeing participants' outstanding performance!

In another world, a programming contest has been held once a year since year y1y_1, except for the nn years s1,s2,,sns_1, s_2, \cdots, s_n when it was not held due to special reasons.

Calculate the number of times the competition has been held up to year y2y_2 (inclusive).

输入格式

There are multiple test cases. The first line of the input contains an integer TT (1T201 \le T \le 20) indicating the number of test cases. For each test case:

The first line contains an integer y1y_1 (1970y199991970 \le y_1 \le 9999) indicating the first year when the contest was held.

The second line first contains an integer nn (0n1000 \le n \le 100) indicating the number of years the contest was not held. Then nn integers s1,s2,,sns_1, s_2, \cdots, s_n (y1<si9999y_1 < s_i \le 9999) follow, indicating the years when the contest was not held. These years are given in increasing order and have no duplicates.

The third line contains an integer y2y_2 (y1y29999y_1 \le y_2 \le 9999). It's guaranteed that y2y_2 is not a year when the contest was not held.

输出格式

For each test case output one line containing one integer, indicating the number of times the competition has been held up to year y2y_2 (inclusive).

题目大意

【题目描述】

广东省是全国较早一批将程序设计竞赛引入省内大学生竞赛体系的省份之一。20032003 年,中山大学承办了第一届广东省大学生程序设计竞赛。此后,华南农业大学、华南理工大学、华南师范大学等省内高校也先后承办了此赛事,除 20202020 年因疫情停办外,每年一届。20232023 年,深圳技术大学将承办第二十届广东省大学生程序设计竞赛,让我们期待选手们出色的表现!

在另一个世界中,某程序设计竞赛自 y1y_1 年起开始举办。除了 s1,s2,,sns_1, s_2, \cdots, s_nnn 年由于特殊原因无法举办之外,其他年份每年举办一次。

y2y_2 年是该竞赛的第几次举办。

【输入格式】

有多组测试数据。第一行输入一个整数 TT1T201 \le T \le 20)表示测试数据组数。对于每组测试数据:

第一行输入一个整数 y1y_11970y199991970 \le y_1 \le 9999),表示该竞赛第一次举办的年份。

第二行首先输入一个整数 nn0n1000 \le n \le 100)表示该竞赛停办的年份数,之后输入 nn 个整数 s1,s2,,sns_1, s_2, \cdots, s_ny1<si9999y_1 < s_i \le 9999)表示该竞赛的停办年份。停办年份按递增顺序给出,且没有重复的年份。

第三行输入一个整数 y2y_2y1y29999y_1 \le y_2 \le 9999)。保证 y2y_2 不是停办年份之一。

【输出格式】

每组数据输出一行一个整数,表示 y2y_2 年是该竞赛的第几次举办。

【样例解释】

对于第一组样例数据,如题目描述中所述,答案为 2020

对于第二组样例数据,由于 20032003 就是该竞赛第 11 次举办的年份,因此答案为 11

对于第三组样例数据,由于竞赛从未停办,因此答案为 34562345+1=11123456 - 2345 + 1 = 1112

对于第四组样例数据,该竞赛前 55 次举办的年份为 3000300030023002300530053006300630073007。因此答案为 55

4
2003
1 2020
2023
2003
1 2020
2003
2345
0
3456
3000
4 3001 3003 3004 3008
3007
20
1
1112
5

提示

For the first sample test case, as described in the problem description, the answer is 2020.

For the second sample test case, because year 20032003 is the 11-st year when the contest was held, the answer is 11.

For the third sample test case, because the contest was held every year, the answer is 34562345+1=11123456 - 2345 + 1 = 1112.

For the fourth sample test case, the first 55 years when the contest was held is 30003000, 30023002, 30053005, 30063006 and 30073007. So the answer is 55.