C. Kuroni and Impossible Calculation
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
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.

Input
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
Output the single number — ∏1≤i<j≤n|ai−aj|modm.

Examples
inputCopy
2 10
8 5
outputCopy
3
inputCopy
3 12
1 4 5
outputCopy
0
inputCopy
3 7
1 4 9
outputCopy
1
Note
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.

题意:就是给了n个数 和一个模数m 求两两之间的差的绝对值 的 乘积 取模m的结果

思路:乍一看 挺吓唬人的 看下m的范围只有1000
思考下 因为
| a_i-a_j |%m=|a_i%m-a_j%m| 一旦n>1000 那么一定存在a_i%m=a_j%m
那么他们的|a_i%m-a_j%m| 这个值就为0 因为是乘积 0任何数都等于0
所以n>1000 直接输出0 否则? 两个for直接暴力

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define me(a,x) memset(a,x,sizeof a)
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define all(x) (x).begin(), (x).end()
#define pb(a) push_back(a)
#define paii pair<int,int>
#define pali pair<ll,int>
#define pail pair<int,ll>
#define pall pair<ll,ll>
#define fi first
#define se second
vector<int> a(200005);
int main()
{
    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) cin>>a[i];

    if(n>1000) puts("0");
    else
    {
        ll ans=1;
        for(int i=1;i<=n;i++){
            for(int j=i+1;j<=n;j++){
                
                ans=abs(a[i]-a[j])%m*ans%m;
                ans=ans%m;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}