Submission #41292


ソースコード

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
#include<bits/stdc++.h>
using namespace std;
long long gcd(long long m,long long n){
long long tmp;
if(m < n){
tmp = n;
n = m;
m = tmp;
}
while(1){
if(n == 0) return m;
tmp = m%n;
m = n;
n = tmp;
}
}
int main(){
int n;
long long a[100];
cin >> n;
for(int i = 0;i < n;i++){
cin >> a[i];
}
long long ltmp;
long long ans = 0;
for(int i = 0;i < n-2;i++){
for(int j = i+1;j < n-1;j++){
ltmp = (a[i] * a[j]) / gcd(a[i],a[j]);
for(int k = j+1;k < n;k++){
ans = max(ans,((ltmp * a[k]) / gcd(ltmp,a[k])));
}
}
}
cout << ans << endl;
return 0;
}

ステータス

項目 データ
問題 0973 - 最大最小公倍数
ユーザー名 ei1719
投稿日時 2018-08-14 21:41:46
言語 C++11
状態 Accepted
得点 1
ソースコード長 688 Byte
最大実行時間 47 ms
最大メモリ使用量 708 KB

セット

セット 得点 Cases
1 ALL 1 / 1 *

テストケース

ファイル名 状態 実行時間 メモリ使用量 #
input-sample1 AC 29 ms 480 KB
1
input-sample2 AC 22 ms 708 KB
1
input-sample3 AC 23 ms 560 KB
1
input01 AC 30 ms 412 KB
1
input02 AC 22 ms 516 KB
1
input03 AC 23 ms 364 KB
1
input04 AC 34 ms 472 KB
1
input05 AC 37 ms 444 KB
1
input06 AC 43 ms 548 KB
1
input07 AC 37 ms 652 KB
1
input08 AC 23 ms 500 KB
1
input09 AC 19 ms 604 KB
1
input10 AC 47 ms 572 KB
1
input11 AC 27 ms 548 KB
1
input12 AC 31 ms 656 KB
1