CF1305C.Kuroni and Impossible Calculation
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
To become the king of Codeforces, Kuroni has to solve the following problem.
He is given n numbers a1,a2,…,an . Help Kuroni to calculate ∏1≤i<j≤n∣ai−aj∣ . As result can be very big, output it modulo m .
If you are not familiar with short notation, ∏1≤i<j≤n∣ai−aj∣ is equal to ∣a1−a2∣⋅∣a1−a3∣⋅ … ⋅∣a1−an∣⋅∣a2−a3∣⋅∣a2−a4∣⋅ … ⋅∣a2−an∣⋅ … ⋅∣an−1−an∣ . In other words, this is the product of ∣ai−aj∣ for all 1≤i<j≤n .
输入格式
The first line contains two integers n , m ( 2≤n≤2⋅105 , 1≤m≤1000 ) — number of numbers and modulo.
The second line contains n integers a1,a2,…,an ( 0≤ai≤109 ).
输出格式
Output the single number — ∏1≤i<j≤n∣ai−aj∣modm .
输入输出样例
输入#1
2 10 8 5
输出#1
3
输入#2
3 12 1 4 5
输出#2
0
输入#3
3 7 1 4 9
输出#3
1
说明/提示
In the first sample, ∣8−5∣=3≡3mod10 .
In the second sample, ∣1−4∣⋅∣1−5∣⋅∣4−5∣=3⋅4⋅1=12≡0mod12 .
In the third sample, ∣1−4∣⋅∣1−9∣⋅∣4−9∣=3⋅8⋅5=120≡1mod7 .