Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |
Tags
- 자료구조
- coding
- 문제풀이
- vector
- 컴퓨터공학과
- 구현
- 오에스
- 컴공과
- 코테
- 브루트포스
- 너비우선탐색
- 정석학술정보관
- cs
- 정석
- 컴공
- Computer science
- bfs
- 백준
- c++
- OS
- 코딩
- 북리뷰
- 오퍼레이팅시스템
- DP
- 알고리즘
- Stack
- 그래프
- 개발
- Operating System
- 스택
Archives
- Today
- Total
Little Jay
[C++] 백준 2702번 - 초6 수학 본문
간단한 gcd, lcm 문제
#include <iostream>
using namespace std;
int gcd(int a, int b) {
if (a % b == 0)
return b;
return gcd(b, a % b);
}
int lcm(int a, int b) {
return a * b / gcd(a, b);
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
int x, y;
cin >> x >> y;
cout << lcm(x, y) << " " << gcd(x, y) << "\n";
}
return 0;
}'알고리즘 > BOJ' 카테고리의 다른 글
| [C++] 백준 13241번 - 최소공배수 (0) | 2021.08.21 |
|---|---|
| [C++] 백준 11508번 - 2 + 1 세일 (0) | 2021.08.21 |
| [C++] 백준 1912번 - 연속합 (0) | 2021.08.21 |
| [C++] 백준 1850번 - 최대공약수 (0) | 2021.08.21 |
| [C++] 백준 5430번 틀 (0) | 2021.08.20 |
Comments