-
Notifications
You must be signed in to change notification settings - Fork 2
/
135.txt
91 lines (59 loc) · 1.28 KB
/
135.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import java.util.Scanner;
import java.math.BigInteger;
public class Main {
static BigInteger ebob(BigInteger a,BigInteger b)
{
BigInteger c;
c=(a.multiply(b)).divide(a.gcd(b));
return c;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n;
BigInteger[] a = new BigInteger[100];
BigInteger y = new BigInteger("1");
BigInteger z = new BigInteger("1");
BigInteger c = new BigInteger("1");
n=scan.nextInt();
for(int i=1;i<=n;i++)
{
a[i]=scan.nextBigInteger();
}
c=a[1];
for(int i=2;i<=n;i++)
{
c=ebob(c,a[i]);
}
System.out.println(c);
}
}
#include <cstdlib>
#include <iostream>
using namespace std;
unsigned long long ekob(unsigned long long a,unsigned long long b)
{
unsigned long long x,y,c;
x=a;
y=b;
while(b!=0)
{
a=a%b;
c=a;
a=b;
b=c;
}
return x*y/a;
}
unsigned long long i,a[22],n;
int main(int argc, char *argv[])
{
scanf("%llu",&n);
for(i=1; i<=n; i++)
scanf("%llu",&a[i]);
for(i=2; i<=n; i++)
{
a[i]=ekob(a[i-1],a[i]);
}
printf("%llu\n",a[n]);
return EXIT_SUCCESS;
}