找到最小的数满足里面有n个不被x整除的整数,m个不被y整除的数,且这n个数和m个数完全不重合。x和y都是质数
int n, m,a,b;
//int a[N];
bool check(int x){
int n1=x/a;
int m1=x/b;
int c=x/(a*b);
int p=n1-c,q=m1-c;
int lf=x-n1-m1+c;
int p1=max(m-p,0LL);
int q1=max(n-q,0LL);
if(p1+q1<=lf)return true;
return false;
}
void solve(){
cin>>n>>m>>a>>b;
int l=0,r=2e9;
while(l<r){
int mid=(l+r)>>1;
if(check(mid))r=mid;
else l=mid+1;
}
cout<<l<<endl;
}
标签:q1,int,容斥,画图,mid,动手,m1,n1,check
From: https://www.cnblogs.com/mathiter/p/18117947