

Hãy luôn nhớ cảm ơn và vote 5*
nếu câu trả lời hữu ích nhé!
uses crt;
var a:array[0..1000000] of longint;
res:qword;
i, n:longint;
function lcm(a:qword; b:longint):qword;
var tmp, t:qword;
begin
t:=a * b;
if t = 0 then exit(a + b);
while b <> 0 do
begin
tmp:=a mod b;
a:=b;
b:=tmp;
end;
exit(t div a);
end;
begin
clrscr;
readln(n);
res:=0;
for i:=1 to n do
begin
read(a[i]);
res:=lcm(res, a[i]);
end;
writeln(res);
for i:=1 to n do writeln(res div a[i]);
readln
end.
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 faster ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
ll n, a[1005], res = 1;
ll bcln(ll a, ll b)
{
return a * b / __gcd(a, b);
}
int main()
{
cin >> n;
for( ll i = 1; i <= n; i++)
{
cin >> a[i];
res = bcln(res, a[i]);
}
cout << res << '\n';
for ( ll i = 2; i <= n; i++)
cout << res/a[i] << " ";
}
Hãy giúp mọi người biết câu trả lời này thế nào?
Bảng tin
6
17
5
https://hoidap247.com/cau-hoi/2686290 lm giúp vs ạ