样例可过,TLE第一个点。
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e6+6;
inline int read()
{
int x=0,y=1;char c=getchar();
while(c<'0'||c>'9'){if(c=='-') y=-y;c=getchar();}
while(c>='0'&&c<='9'){x=x*10+(c^'0');c=getchar();}
return x*y;
}
int n,m,cnt,pri[N];
bool ton[N];
signed main()
{
for(int i=2;i<=N/10;i++)
{
if(!ton[i]) pri[++cnt]=i;
for(int j=1;j<=cnt&&i*pri[j]<=N/10;j++)
{
ton[i*pri[j]]=true;
if(i%pri[j]==0) break;
}
}
int T=read();
while(T--)
{
memset(ton,false,sizeof ton);
n=read();
for(int i=1;i<=n;i++)
{
int a=read();
for(int j=1;j<=cnt;j++)
{
if(a%pri[j]) continue;
ton[pri[j]]=true;
while(!(a%pri[j])) a/=pri[j];
if(a==1) break;
}
}
for(int i=1;i<=cnt;i++)
{
if(ton[pri[i]]) continue;
else {printf("%lld\n",pri[i]);break;}
}
}
return 0;
}