#include <iostream>
#include <string>
#include <vector>
using namespace std;
long long int gcd(int a,int b){
if(b==0) return a;
else return gcd(b,a%b);
}
int solution(vector<int> arr) {
int answer = 0;
long long int gcd_value=1,lcm_value=1;
if(arr.size()==1) lcm_value=arr[0];
else{
lcm_value = arr[0];
for(int i=1; i<arr.size(); i++){
lcm_value = (lcm_value * arr[i]) / gcd(lcm_value,arr[i]);
}
}
answer=lcm_value;
return answer;
}
'Algorithm ๐ง๐ปโ๐ป > ํ๋ก๊ทธ๋๋จธ์ค(Programmers)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ๊ฐ์ ์ซ์๋ ์ซ์ด (Level 1) (0) | 2021.10.19 |
---|---|
[c++] ํ๋ก๊ทธ๋๋จธ์ค - ๊ฐ์ฅ ํฐ ์ (Level 2) (0) | 2021.10.19 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - [1์ฐจ] ๋ด์ค ํด๋ฌ์คํฐ๋ง ( Level 2, 2018 KAKAO BLIND RECRUITMENT ) (0) | 2021.10.19 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - K๋ฒ์งธ ์ ( Level 1) (0) | 2021.10.19 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - JadenCase ๋ฌธ์์ด ๋ง๋ค๊ธฐ ( Level 2 ) (0) | 2021.10.19 |
[c++] ํ๋ก๊ทธ๋๋จธ์ค - H-Index ( Level 2 ) (0) | 2021.10.19 |
๋๊ธ