P9690 [GDCPC 2023] Programming Contest

题目描述

广东省是全国较早一批将程序设计竞赛引入省内大学生竞赛体系的省份之一。$2003$ 年,中山大学承办了第一届广东省大学生程序设计竞赛。此后,华南农业大学、华南理工大学、华南师范大学等省内高校也先后承办了此赛事,除 $2020$ 年因疫情停办外,每年一届。$2023$ 年,深圳技术大学将承办第二十届广东省大学生程序设计竞赛,让我们期待选手们出色的表现! 在另一个世界中,某程序设计竞赛自 $y_1$ 年起开始举办。除了 $s_1, s_2, \cdots, s_n$ 这 $n$ 年由于特殊原因无法举办之外,其他年份每年举办一次。 求 $y_2$ 年是该竞赛的第几次举办。 对于第二组样例数据,由于 $2003$ 就是该竞赛第 $1$ 次举办的年份,因此答案为 $1$。 对于第三组样例数据,由于竞赛从未停办,因此答案为 $3456 - 2345 + 1 = 1112$。 对于第四组样例数据,该竞赛前 $5$ 次举办的年份为 $3000$,$3002$,$3005$,$3006$ 与 $3007$。因此答案为 $5$。

输入格式

有多组测试数据。第一行输入一个整数 $T$($1 \le T \le 20$)表示测试数据组数。对于每组测试数据: 第一行输入一个整数 $y_1$($1970 \le y_1 \le 9999$),表示该竞赛第一次举办的年份。 第二行首先输入一个整数 $n$($0 \le n \le 100$)表示该竞赛停办的年份数,之后输入 $n$ 个整数 $s_1, s_2, \cdots, s_n$($y_1 < s_i \le 9999$)表示该竞赛的停办年份。停办年份按递增顺序给出,且没有重复的年份。 第三行输入一个整数 $y_2$($y_1 \le y_2 \le 9999$)。保证 $y_2$ 不是停办年份之一。

输出格式

每组数据输出一行一个整数,表示 $y_2$ 年是该竞赛的第几次举办。 **【样例解释】**

说明/提示

For the first sample test case, as described in the problem description, the answer is $20$. For the second sample test case, because year $2003$ is the $1$-st year when the contest was held, the answer is $1$. For the third sample test case, because the contest was held every year, the answer is $3456 - 2345 + 1 = 1112$. For the fourth sample test case, the first $5$ years when the contest was held is $3000$, $3002$, $3005$, $3006$ and $3007$. So the answer is $5$.