AT_arc223_c.Whole Product of Pairwise Distances

提高+/省选-

通过率:0%

时间限制:2.00s

内存限制:1024MB

AC君温馨提醒

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

题目描述

You are given a sequence AA of NN positive integers.
Find the remainder when ∏1≤i<j≤N∣Ai−Aj∣\prod_{1 \leq i < j \leq N}|A_i-A_j| is divided by NN.

Solve TT test cases per input.

给你一个长度为 NN 的正整数序列 AA。
求 ∏1≤i<j≤N∣Ai−Aj∣\prod_{1 \leq i < j \leq N}|A_i-A_j| 除以 NN 的余数。

每组输入包含 TT 个测试用例。

输入格式

The input is given from Standard Input in the following format:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

Each test case caset\mathrm{case}_t is given in the following format:

NN
A1A_1 A2A_2 …\ldots ANA_N

输入从标准输入中按以下格式给出:

TT
case1\mathrm{case}_1
case2\mathrm{case}_2
⋮\vdots
caseT\mathrm{case}_T

每个测试用例 caset\mathrm{case}_t 按以下格式给出:

NN
A1A_1 A2A_2 …\ldots ANA_N

输出格式

Output the answers over a total of TT lines. The tt-th line should contain the answer for the tt-th test case.

在总共 TT 行中输出答案。第 tt 行应包含第 tt 个测试用例的答案。

输入输出样例

  • 输入#1

    3
    3
    1 9 5
    3
    2 2 3
    5
    11 33 22 55 44

    输出#1

    2
    0
    3

说明/提示

Sample 1 Explanation:
For the first test case, ∣A1−A2∣×∣A1−A3∣×∣A2−A3∣=8×4×4=128|A_1-A_2| \times |A_1-A_3| \times |A_2-A_3|=8 \times 4 \times 4=128, and the remainder when this is divided by 33 is 22.

Constraints

  • 1≤T≤1051 \leq T \leq 10^5
  • 2≤N≤2×1052 \leq N \leq 2 \times 10^5
  • 1≤Ai≤1091 \leq A_i \leq 10^9
  • The sum of NN over all test cases is at most 2×1052 \times 10^5.
  • All input values are integers.

样例 1 解释:
对于第一个测试用例,∣A1−A2∣×∣A1−A3∣×∣A2−A3∣=8×4×4=128|A_1-A_2| \times |A_1-A_3| \times |A_2-A_3|=8 \times 4 \times 4=128,该值除以 33 的余数为 22。

约束条件

  • 1≤T≤1051 \leq T \leq 10^5
  • 2≤N≤2×1052 \leq N \leq 2 \times 10^5
  • 1≤Ai≤1091 \leq A_i \leq 10^9
  • 所有测试用例的 NN 之和不超过 2×1052 \times 10^5。
  • 所有输入值均为整数。

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

首页