Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
FurinaForcalos
/**
* author: furinaforcalos
* created: 16.03.2025
**/
#include <bits/stdc++.h>
using namespace std;
#define hutao long long
hutao dp[1005],x[100];
hutao p[15]={2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47};
hutao getbit(hutao n,hutao k)
{
return (n>>k)&1;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
hutao k,n,j=0,ans=1e18;
cin>>n;
for(hutao i=1;i<=n;i++)
{
cin>>x[i];
}
for(hutao mask=1;mask<=(1<<15)-1;mask++)
{
hutao m=1,ok=1;
for(hutao i=0;i<=14;i++)
if(getbit(mask,i))
m*=p[i];
for(hutao i=1;i<=n;i++)
if(__gcd(m,x[i])==1)
ok=0;
if(ok)
ans=min(ans,m);
}
cout<<ans;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
#include<bits/stdc++.h>
#define ll long long
#define db double
#define str string
#define fi first
#define se second
#define mod 1000000007
#define maxn 100000
#define si size()
using namespace std;
ll test(ll t)
{
for(ll i=2;i<=sqrt(t);i++) if(t%i==0) return i;
return t;
}
int main()
{
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
ll n;
cin>>n;
set<ll> a;
ll t;
while(n--)
{
cin>>t;
a.insert(test(t));
}
ll s=1;
for(ll i:a) s*=i;
cout<<s;
return 0;
}
Hãy giúp mọi người biết câu trả lời này thế nào?
CÂU HỎI MỚI NHẤT
Giải giúp mìnhh với ạ
226
3392
72
cái này gọi là gì nhỉ =)
1431
3645
2396
thế mà chx j đã nói suy nghĩ trc nói đi ?
226
3392
72
gọi nhầm tên
1431
3645
2396
đọc cho kĩ
226
3392
72
để tác giả chấm thử
1431
3645
2396
full k bao h sai đc
226
3392
72
là đang nói code cậu ak hả =)
1431
3645
2396
uk