AT_arc223_c.Whole Product of Pairwise Distances
提高+/省选-
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a sequence A of N positive integers.
Find the remainder when ∏1≤i<j≤N∣Ai−Aj∣ is divided by N.
Solve T test cases per input.
给你一个长度为 N 的正整数序列 A。
求 ∏1≤i<j≤N∣Ai−Aj∣ 除以 N 的余数。
每组输入包含 T 个测试用例。
输入格式
The input is given from Standard Input in the following format:
T
case1
case2
⋮
caseT
Each test case caset is given in the following format:
N
A1 A2 … AN
输入从标准输入中按以下格式给出:
T
case1
case2
⋮
caseT
每个测试用例 caset 按以下格式给出:
N
A1 A2 … AN
输出格式
Output the answers over a total of T lines. The t-th line should contain the answer for the t-th test case.
在总共 T 行中输出答案。第 t 行应包含第 t 个测试用例的答案。
输入输出样例
输入#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, and the remainder when this is divided by 3 is 2.
Constraints
- 1≤T≤105
- 2≤N≤2×105
- 1≤Ai≤109
- The sum of N over all test cases is at most 2×105.
- All input values are integers.
样例 1 解释:
对于第一个测试用例,∣A1−A2∣×∣A1−A3∣×∣A2−A3∣=8×4×4=128,该值除以 3 的余数为 2。
约束条件
- 1≤T≤105
- 2≤N≤2×105
- 1≤Ai≤109
- 所有测试用例的 N 之和不超过 2×105。
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?