C 求复合 SDUT


Problem Description

小啵的女朋友非常喜欢数字,而小啵的女朋友在和他在闹分手。他拥有n个数字,今天他又获得了一个数字m,小啵需要利用这n个数和数字m求出一个神奇的数ans = (∏1≤i


Input

第一行输入两个数字,n, m;(2≤n≤200000, 1≤m≤1000);

第二行输入n个数字,a1, a2, a3, …, an;(0≤ai≤1e9);


Output

一个单独的数字, ∏1≤i


Sample Input

2 10
8 5


Sample Output

3


Hint

∏1≤i


Source
bo sherry


#include 
#include
typedef long long ll;
int n;
ll m;
ll a[200005];
int main()
{
    int i,j;
	scanf("%d %lld",&n,&m);
	for(i=1;i<=n;i++)
        scanf("%lld",&a[i]);
	if(n>m)
	{
		printf("%d\n",0);
		return 0;
	}
	ll ans=1;
	for(i=1;i<=n;i++)
	{
		for(j=i+1;j<=n;j++)
		{
			ans=ans*abs(a[i]-a[j])%m;

		}
	}
	printf("%lld\n",ans);
	return 0;
 }

你可能感兴趣的:(其他)