题解:
每个质数新建点跑最大匹配即可。
#include <bits/stdc++.h>
using namespace std;
const int RLEN=1<<18|1;
inline char nc() {
static char ibuf[RLEN],*ib,*ob;
(ib==ob) && (ob=(ib=ibuf)+fread(ibuf,1,RLEN,stdin));
return (ib==ob) ? -1 : *ib++;
}
inline int rd() {
char ch=nc(); int i=0,f=1;
while(!isdigit(ch)) {
if(ch=='-')f=-1; ch=nc();}
while(isdigit(ch)) {
i=(i<<1)+(i<<3)+ch-'0'; ch=nc();}
return i*f;
}
const int N=1e6+50, M=1e7+50, inf=1e9;
int n,a[N],b[N],tot;
set <int> sa;
map <int,int> sb;
namespace mcmf {
int g[N],nt[M]