κ°œμΈκ³΅λΆ€/Algorithm

[λ°±μ€€][Node.js] 2609번 : μ΅œλŒ€κ³΅μ•½μˆ˜μ™€ μ΅œμ†Œκ³΅λ°°μˆ˜

πŸ‡λ°•λ΄‰λ΄‰πŸ‡ 2021. 9. 4. 22:59

 

 

Algorithm

-  μ΅œλŒ€κ³΅μ•½μˆ˜μ™€ μ΅œμ†Œκ³΅λ°°μˆ˜ -

 


 

문제

두 개의 μžμ—°μˆ˜λ₯Ό μž…λ ₯λ°›μ•„ μ΅œλŒ€ κ³΅μ•½μˆ˜μ™€ μ΅œμ†Œ 곡배수λ₯Ό 좜λ ₯ν•˜λŠ” ν”„λ‘œκ·Έλž¨μ„ μž‘μ„±ν•˜μ‹œμ˜€. 

 

μž…μΆœλ ₯ μ˜ˆμ‹œ

 

문제 ν’€κΈ°

const readline = require("readline");
const rl = readline.createInterface({
	input: process.stdin,
	output: process.stdout,
});
let input;
rl.on("line", function (line) {
	input = line
		.toString()
		.split(" ")
		.map((el) => +el);
}).on("close", function () {
	let result = []; // μ΅œλŒ€κ³΅μ•½μˆ˜, μ΅œμ†Œκ³΅λ°°μˆ˜
	let big = Math.max(...input);
	for (let i = big; i >= 0; i--) {
		if (input[0] % i === 0 && input[1] % i === 0) {
			result.push(i);
			break;
		}
	}
	result.push(
		result[0] * parseInt(input[0] / result[0]) * parseInt(input[1] / result[0])
	);
	console.log(result.join("\n"));
	process.exit();
});

 

 

 

λ°˜μ‘ν˜•