有n个正整数a[i],设它们乘积为p,你可以给p乘上一个正整数q,使p*q刚好为正整数m的阶乘,求m的最小值。
额简单的数学(我是真的爱数学)
二分答案很明显合法
怎么判断:对每个质数做向下取整除法:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
#define LL long long
inline void read(int &x){
x=0;
char ch=getchar();
int f=1;
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
x=x*10+ch-'0';
ch=getchar();
}
x*=f;
}
const int N=1e5+1e4;
const int maxn=1e5+10;
int Prime[N];
int vis[N];
int cnt=0;
void Pre(){
for(int i=2;i<=maxn;++i){
if(!vis[i]){
Prime[++cnt]=i;
}
for(int j=1;j<=cnt&&Prime[j]*i<=maxn;++j){
vis[i*Prime[j]]=1;
if(i%Prime[j]==0)break;
}
}
}
int C[N];
int val[N];
void Solve(LL x){
for(LL i=2;i*i<=x;++i){
while(x%i==0){
++C[i];
x/=i;
}
}
if(x>1)++C[x];
}
int now=0;
LL Goal=-1;
bool Check(LL x){
for(LL i=1;i<=maxn;++i){
if(C[i]){
LL now=i;
LL sum=0;
while(x/now){
sum+=x/now;
now=now*i;
}
if(sum<C[i])return false;
}
}
return true;
}
int n;
int main(){
freopen("fact.in","r",stdin);
freopen("fact.out","w",stdout);
// Pre();
read(n);
for(int i=1;i<=n;++i){
read(val[i]);
}
for(int i=1;i<=n;++i){
Solve(val[i]);
}
LL m=1;
for(int i=1;i<=maxn;++i)if(C[i])++now;//cout<<i<<" ";
LL l=1;
LL r=1e12;
LL ans=0;
while(l<=r){
LL mid=(l+r)>>1;
if(Check(mid)){
ans=mid;
r=mid-1;
}
else l=mid+1;
}
cout<<ans;
return 0;
}