RT,
大致意思就是当 n≥3 时只有数字两两互质才能Yes,否则No。
这是我的赛时代码:
#include<bits/stdc++.h>
using namespace std;
const int N=1e8+5;
bitset<N> mark;
int T,n;
int m;
int A[500005];
bool ans=true;
int main(){
//freopen("C2.in","r",stdin);
ios::sync_with_stdio(false);
cin>>T;
while(T--){
mark.reset();
ans=true;
cin>>n;
if(n==2){
cout<<"Yes\n";
}
for(int i = 1; i<=n; i++){
cin>>A[i];
}
if(n==2) continue;
//sort(A+1,A+1+n,[](int a,int b){return a>b;});
br:
for(int i = 1; i<=n; i++){
m=A[i];
//cout<<m<<' ';
if(!ans) continue;
if(mark.test(m)){
ans=false;
}
mark.set(m,1);
for(int j = 2; j*j<=m; j++){
if(m%j==0){
if(mark.test(j)){
ans=false;
goto br;
}
while(m^1){
mark.set(m,1);
if(mark.test(m/j)&&(m^j)){
ans=false;
goto br;
}
m/=j;
}
}
//cout<<endl;
}
}
cout<<(ans?"Yes\n":"No\n");
}
return 0;
}
while(m^1)处其实是想搞一个类似于质因数分解的效果(应该是 while(m%j==0),while(m^1)的意思是 while(m!=1)),但是改过之后反而分数降到12分左右。
但是这错误的解法能得到 84 分,谔谔。