CF1935D.Exam in MAC

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Master's Assistance Center has announced an entrance exam, which consists of the following.

The candidate is given a set ss of size nn and some strange integer cc. For this set, it is needed to calculate the number of pairs of integers (x,y)(x, y) such that 0≤x≤y≤c0 \leq x \leq y \leq c, x+yx + y is not contained in the set ss, and also y−xy - x is not contained in the set ss.

Your friend wants to enter the Center. Help him pass the exam!

大师援助中心宣布了一次入学考试,考试内容如下:

考生将获得一个大小为 nn 的集合 ss 和某个奇怪的整数 cc。对于该集合,需要计算满足以下条件的整数对 (x,y)(x, y) 的数量:

  • 0≤x≤y≤c0 \leq x \leq y \leq c,
  • x+y∉sx + y \notin s,
  • y−x∉sy - x \notin s。

你的朋友希望进入该中心。请帮助他通过这次考试!

输入格式

Each test consists of multiple test cases. The first line contains a single integer tt (1≤t≤2⋅1041 \leq t \leq 2 \cdot 10^4) — the number of test cases. The description of the test cases follows.

The first line of each test case contains two integers nn and cc (1≤n≤3⋅1051 \leq n \leq 3 \cdot 10^5, 1≤c≤1091 \leq c \leq 10^9) — the size of the set and the strange integer.

The second line of each test case contains nn integers s1,s2,…,sns_1, s_2, \ldots, s_{n} (0≤s1<s2<…<sn≤c0 \leq s_1 \lt s_2 \lt \ldots \lt s_{n} \leq c) — the elements of the set ss.

It is guaranteed that the sum of nn over all test cases does not exceed 3⋅1053 \cdot 10^5.

每个测试包含多个测试用例。第一行包含一个整数 tt(1≤t≤2⋅1041 \leq t \leq 2 \cdot 10^4),表示测试用例的数量。随后是各测试用例的描述。

每个测试用例的第一行包含两个整数 nn 和 cc(1≤n≤3⋅1051 \leq n \leq 3 \cdot 10^5,1≤c≤1091 \leq c \leq 10^9),分别表示集合的大小和该“特殊”整数。

每个测试用例的第二行包含 nn 个整数 s1,s2,…,sns_1, s_2, \ldots, s_{n}(0≤s1<s2<…<sn≤c0 \leq s_1 \lt s_2 \lt \ldots \lt s_{n} \leq c),表示集合 ss 的元素。

保证所有测试用例中 nn 的总和不超过 3⋅1053 \cdot 10^5。

输出格式

For each test case, output a single integer — the number of suitable pairs of integers.

对于每个测试用例,输出一个整数——满足条件的整数对的数量。

输入输出样例

  • 输入#1

    8
    3 3
    1 2 3
    1 179
    57
    4 6
    0 3 5 6
    1 1
    1
    5 10
    0 2 4 8 10
    5 10
    1 3 5 7 9
    4 10
    2 4 6 7
    3 1000000000
    228 1337 998244353

    输出#1

    3
    16139
    10
    2
    33
    36
    35
    499999998999122959

说明/提示

In the first test case, the following pairs are suitable: (0,0)(0, 0), (2,2)(2, 2), (3,3)(3, 3).

In the third test case, the following pairs are suitable: (0,1)(0, 1), (0,2)(0, 2), (0,4)(0, 4), (1,3)(1, 3), (2,6)(2, 6), (3,4)(3, 4), (3,5)(3, 5), (4,5)(4, 5), (4,6)(4, 6), (5,6)(5, 6).

在第一个测试用例中,以下数对是合适的:(0,0)(0, 0)、(2,2)(2, 2)、(3,3)(3, 3)。

在第三个测试用例中,以下数对是合适的:(0,1)(0, 1)、(0,2)(0, 2)、(0,4)(0, 4)、(1,3)(1, 3)、(2,6)(2, 6)、(3,4)(3, 4)、(3,5)(3, 5)、(4,5)(4, 5)、(4,6)(4, 6)、(5,6)(5, 6)。

输入解题思路,AI测评打分。不知道怎么写?

首页