#P9690. [GDCPC 2023] Programming Contest

[GDCPC 2023] 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).

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.