差不多的代码为什么耗时相差那么多啊!!求大佬解答
`#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include <iostream>
using namespace std;
long long a[100010];
long long m,n;
long long b[100010],c[100010];
int main()
{
while(scanf("%LLd %LLd",&n,&m)!=EOF)
{
b[0]=1;
c[n+1]=1;
for(int i=1;i<n+1;i++)
{
scanf("%LLd",&a[i]);
a[i]%=m;
b[i]=(b[i-1]*a[i])%m;
}
for(int i=n;i>=1;i--)
{
c[i]=(c[i+1]*a[i])%m;
}
for(int i=1;i<=n;i++)
{
if(i==n)printf("%LLd\n",(c[i+1]*b[i-1])%m);
else printf("%LLd ",(c[i+1]*b[i-1])%m);
}
}
return 0;
}
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
typedef long long LL;
const int maxn=100005;
int n,m;
LL a[maxn];
LL b[maxn],c[maxn];
int main()
{
while(scanf("%d %d",&n,&m)!=EOF)
{
b[0]=1;c[n+1]=1;
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
a[i]%=m;
b[i]=(b[i-1]*a[i])%m;
}
for(int i=n;i>=1;i--)
c[i]=(c[i+1]*a[i])%m;
for(int i=1;i<n;i++)
{
printf("%lld ",(b[i-1]*c[i+1])%m);
}
printf("%lld\n",b[n-1]);
}
return 0;
}