반응형
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 |
Tags
- Unsupervised learning
- 추천 시스템
- pre-trained
- OpenGL
- recommender system
- 딥러닝
- SGD
- Kaggle
- CNN
- cs231n
- 그래픽스
- 신경망
- C++
- SVM
- logistic regression
- 머신러닝
- Vision
- 백준
- 로지스틱 회귀
- 인공지능
- 컴퓨터 그래픽스
- Support Vector Machine
- 컴퓨터 비전
- neural network
- 비용함수
- Computer Vision
- 파이썬
- petal to metal
- CPP
- Regularization
Archives
- Today
- Total
kwan's note
백준 2609번 최대공약수 최소공배수 파이썬 (python code) 본문
반응형
2609번
실버5
2609번: 최대공약수와 최소공배수
첫째 줄에는 입력으로 주어진 두 수의 최대공약수를, 둘째 줄에는 입력으로 주어진 두 수의 최소 공배수를 출력한다.
www.acmicpc.net
최대공약수 최소공배수를 구하는 간단한 문제다.
유클리드호제법으로 gcd를 구하고 이를이용해 lcm을 구했다.
코드는 시간이 남을것같아서 시간에 관계없이 짧고 간결하게 작성해보았다.
num1 , num2= map(int,input().split())
def gcd(a,b):
return b if a%b==0 else gcd(b,a%b)
print(gcd(num1,num2))
print(num1*num2//gcd(num1,num2))
반응형
'Algorithm > python' 카테고리의 다른 글
백준 1010번 다리놓기 파이썬 (python code) (1) | 2021.01.17 |
---|---|
백준 2981번 검문 파이썬 (python code) (1) | 2021.01.16 |
백준 1931번 회의실 배정 파이썬 (python code) (0) | 2021.01.15 |
백준 9251번 LCS 파이썬 (python code) (0) | 2021.01.15 |
백준 11053번 가장 긴 증가하는 부분 수열 (Lis) 파이썬 (python code) (0) | 2021.01.15 |