

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
#include <bits/stdc++.h>
using namespace std;
int res,n;
int a[101];
void input()
{
cin>>n;
for (int i=1;i<=n;i++) cin>>a[i];
}
long long bcnn(long long a,long long b)
{
long long s=a*b/__gcd(a,b);
return s;
}
void solve()
{
res=a[1];
for (int i=2;i<=n;i++)
{
res=bcnn(res,a[i]);
}
cout<<res<<endl;
for (int i=1;i<=n;i++)
{
cout<<res/a[i]<<" ";
}
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
input();
solve();
}
Hãy giúp mọi người biết câu trả lời này thế nào?
![]()
Bảng tin