update 还有一种更秀的做法,碾爆正解
#include
#include
#include
#include
#define ll long long
#define mo 998244353
#define maxp 10005
using namespace std;
int id,T,c,m,mm,i,j,k,p;
int tot,pri[maxp],bz[maxp],f[maxp];
ll ans,cnt;
int ksm(int x,int y){
ll s=1;
for(;y;y/=2,x=x*x%p) if (y&1)
s=s*x%p;
return s;
}
int main(){
for(i=2;i
#include
#include
#include
#include
#define ll long long
#define mo 998244353
#define maxp 10005
using namespace std;
int id,T,c,m,mm,i,j,k,p;
ll ans,cnt;
int gcd(int x,int y){
return (x%y==0)?y:gcd(y,x%y);
}
int main(){
scanf("%d",&id);
scanf("%d",&T);
while (T--){
scanf("%d%d",&c,&m);
ans=1;
while (c--){
scanf("%d",&p);
ans=1ll*ans*(gcd(m-1,p-1)+1)%mo;
}
printf("%lld\n",ans);
}
}