Codeforces 1305C Kuroni and Impossible Calculation
题意,给你一个数组,求\(\prod_{1\le i<j\le n} |a_i - a_j|\)对\(m\)取模
分析数据,n是2e5, 而m是1000, 那肯定要从m下手,若\(m\le m\), 那么可以直接暴力求解, 若\(n>m\), 一定存在\(a_i, a_j\), 使得\(|a_i-a_j|\)一定能被\(m\)整除
#include<bits/stdc++.h>
using namespace std;
#define ms(x,y) memset(x, y, sizeof(x))
#define lowbit(x) ((x)&(-x))
typedef long long LL;
typedef pair<int,int> pii;
const int maxn = 1005;
LL buf[maxn];
void run_case() {
int n, m;
cin >> n >> m;
if(m < n) {
cout << "0\n";
return;
} else {
for(int i = 1; i <= n; ++i) cin >> buf[i];
LL ans = 1;
for(int i = 1; i <= n; ++i)
for(int j = i+1; j <= n; ++j) {
ans = (ans * abs(buf[i] - buf[j])) % m;
}
cout << ans%m;
}
}
int main() {
ios::sync_with_stdio(false), cin.tie(0);
cout.flags(ios::fixed);cout.precision(2);
//int t; cin >> t;
//while(t--)
run_case();
cout.flush();
return 0;
}