From 5e7275f25f3148dbc63dc632bf3eac1261f4a416 Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Tue, 26 Nov 2024 13:35:24 +0000 Subject: [PATCH] =?UTF-8?q?=EC=9D=B4=EC=8A=88=20#391=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=86=94=EB=A3=A8=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\354\235\230_\353\215\247\354\205\210.cpp" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" diff --git "a/Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" "b/Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" new file mode 100644 index 0000000..b0a3fa1 --- /dev/null +++ "b/Programmers/\353\266\204\354\210\230\354\235\230_\353\215\247\354\205\210.cpp" @@ -0,0 +1,25 @@ +#include +#include +#include + +using namespace std; + +int gcd(int a, int b) { + while (b != 0) { + int temp = a % b; + a = b; + b = temp; + } + return a; +} + +vector solution(int numer1, int denom1, int numer2, int denom2) { + int numerator = numer1 * denom2 + numer2 * denom1; + int denominator = denom1 * denom2; + + int common = gcd(numerator, denominator); + numerator /= common; + denominator /= common; + + return {numerator, denominator}; +} \ No newline at end of file