20250626 baekjoon
This commit is contained in:
parent
97f391f309
commit
387d4b1227
24
code_study/Baekjoon/c/2609.c
Normal file
24
code_study/Baekjoon/c/2609.c
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int a, b;
|
||||||
|
scanf("%d %d",&a, &b);
|
||||||
|
if(a<b) {
|
||||||
|
int temp;
|
||||||
|
temp = a;
|
||||||
|
a = b;
|
||||||
|
b = temp;
|
||||||
|
}
|
||||||
|
|
||||||
|
int gcd = a, b_temp = b, r;
|
||||||
|
while(b_temp != 0) {
|
||||||
|
r = gcd % b_temp;
|
||||||
|
gcd = b_temp;
|
||||||
|
b_temp = r;
|
||||||
|
}
|
||||||
|
|
||||||
|
int lcm = a*b/gcd;
|
||||||
|
printf("%d\n%d\n",gcd,lcm);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
7
code_study/Baekjoon/js/2609.js
Normal file
7
code_study/Baekjoon/js/2609.js
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
let [a,b] = require("fs").readFileSync(0,"utf8").toString().trim().split(' ').map(Number);
|
||||||
|
if(a<b) [a,b] = [b,a];
|
||||||
|
const GCD = (x,y) => y!==0 ? GCD(y, x%y) : x;
|
||||||
|
const gcd = GCD(a,b);
|
||||||
|
const lcm = a*b/gcd;
|
||||||
|
console.log(gcd);
|
||||||
|
console.log(lcm);
|
||||||
5
code_study/Baekjoon/python/2609.py
Normal file
5
code_study/Baekjoon/python/2609.py
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
a, b = map(int, input().split())
|
||||||
|
x, y = max(a,b), min(a,b)
|
||||||
|
while y :
|
||||||
|
x, y = y, x%y
|
||||||
|
print(f"{x}\n{a*b//x}")
|
||||||
Loading…
x
Reference in New Issue
Block a user