analysis
The largest group seeking to meet the conditions
We can consider building a complementary graph
It revealed between odd and even among
Since it must satisfy the above must be odd Complements a form into a set of even a bipartite graph
Seeking bipartite graph can be set independently of the maximum
Code
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,m,d[1010],g[1010][1010],a[1010],b[1010],c1,c2,ans,T,used[1010],wh[1010];
inline bool work(int x){
for(int i=1;i<=m;i++)
if(g[x][i]&&used[i]!=T){
used[i]=T;
if(!wh[i]||work(wh[i])){
wh[i]=x;
return 1;
}
}
return 0;
}
inline void go(){
for(int i=1;i<=n;i++){
++T;
if(work(i))ans++;
}
}
signed main(){
int i,j,k;
scanf("%lld",&n);
for(i=1;i<=n;i++){
scanf("%lld",&d[i]);
if(d[i]&1)a[++c1]=d[i];
else b[++c2]=d[i];
}
n=c1,m=c2;
for(i=1;i<=c1;i++)
for(j=1;j<=c2;j++)
if(__gcd(a[i],b[j])==1&&__gcd(a[i]+1,b[j]+1)==1)g[i][j]=1;
go();
printf("%lld",n+m-ans);
return 0;
}