728x90
반응형
- 풀이 링크:
GitHub - xhaktmchl/Algorithm_study: 알고리즘 이론 및 문제풀이
알고리즘 이론 및 문제풀이. Contribute to xhaktmchl/Algorithm_study development by creating an account on GitHub.
github.com
#include <iostream>
#include <algorithm> // fill_n, min,max, swap
//#include <map> // 중복 x
//#include <string> // getline
//#include <cstring> // memset, strok, strstr
//#include <vector>
//#include <queue> // priority_queue<자료형, 구현체, 비교 연산자> (중복허용),
//#include <set> // 트리, 중복 x , multiset
//#include <unordered_set>
//#include <cmath>
using namespace std; // lower_bound, upper_bound
/*
[백준 1934 c++ O] 최소공배수
문제:
접근:
시간복잡도: O()
풀이:
*/
int T;
int A, B;
int divide(int x, int y)
{
if (x % y == 0)
return y;
else return divide(y, x % y);
}
int main()
{
ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(0);
cin >> T;
for (int i = 0; i < T; i++)
{
cin >> A >> B;
if (A >= B) cout << A * B / divide(A, B) << "\n";
else cout << A * B / divide(B, A) << "\n";
}
return 0;
}
반응형
'Algorithm_BOJ(백준) > 수학(Math)' 카테고리의 다른 글
[백준 10610 c++ V] 30 (0) | 2023.01.12 |
---|---|
[백준 1735 c++ O] 분수 합 (0) | 2023.01.12 |
[백준 10430 c++ OO] 나머지 (0) | 2021.12.22 |
[백준 5543 c++ O] 상근날드 (0) | 2021.08.30 |
[백준 2587 c++ O] 대표값2 (0) | 2021.08.30 |