백준 14490 c++
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
void input_num(int* N, int* M)
{
char no;
cin >> *N >> no >> *M;
return;
}
void find_answer(int N, int M)
{
//cout << N << M;
int gcd;
int n, m, temp;
if (N > M)
{
n = N;
m = M;
}
else
{
n = M;
m = N;
}
while (1)
{
temp = n;
n = m;
m = temp % m;
if (m == 0)
{
break;
}
}
gcd = n;
cout << N/gcd <<":"<< M/gcd << "\n";
return;
}
int main(void)
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int N, M;
input_num(&N, &M);
find_answer(N, M);
return 0;
}