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
- 자료구조
- 그래프
- 백준
- c++
- 구현
- 개발
- 오에스
- 컴공
- cs
- 정석
- Computer science
- bfs
- 알고리즘
- 브루트포스
- 너비우선탐색
- 코딩
- coding
- 스택
- 정석학술정보관
- 문제풀이
- 오퍼레이팅시스템
- DP
- 컴퓨터공학과
- Operating System
- OS
- 북리뷰
- Stack
- 코테
- 컴공과
- vector
Archives
- Today
- Total
Little Jay
[C++] 백준 13241번 - 최소공배수 본문
long long을 사용하는 lcm문제
간단하게 재귀로 작성해도 맞았다
#include <iostream>
using namespace std;
long long gcd(long long a, long long b) {
if (a % b == 0)
return b;
return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
return a * b / gcd(a, b);
}
int main() {
long long x, y;
cin >> x >> y;
cout << lcm(x, y) << "\n";
return 0;
}
'알고리즘 > BOJ' 카테고리의 다른 글
[C++] 백준 1747번 - 소수&팰린드롬 (0) | 2021.08.23 |
---|---|
[C++] 백준 5430번 - AC (0) | 2021.08.23 |
[C++] 백준 11508번 - 2 + 1 세일 (0) | 2021.08.21 |
[C++] 백준 2702번 - 초6 수학 (0) | 2021.08.21 |
[C++] 백준 1912번 - 연속합 (0) | 2021.08.21 |
Comments