[[TableOfContents]] = 오늘의 문제 = * [https://www.acmicpc.net/problem/2436|공약수] * 추석이니 쉬운 문제로.. = 참가자 = * 미시행 = 코드 = == 15이원준 == {{{ #include using namespace std; int checker(int f, int s){ int answer; for(int i = 1; i*i<= f; i++){ if(f%i == 0 && s%i == 0){ answer = i; } } return answer; } int main(){ int L,M; scanf("%d %d", &L, &M); int tmp = M / L; int answer; for(int i = 1; i * i <= tmp; i++){ if(tmp % i == 0 && checker(i, tmp/i) == 1){ answer = i; } } cout<< answer * L << " " << tmp*L/answer< int gcd(int a, int b) { while (a%b != 0) { int t = a%b; a = b; b = t; } return b; } int main() { int a, b; std::cin >> a >> b; int c = b / a, r = 1; for (int i = 1; i*i <= c; i++) if (i*(c / i) == c && gcd(i,c/i)==1) r = i; std::cout << a*r << ' ' << a*c / r; return 0; } }}} == 곽정흠 == = 아이디어 = == 15이원준 == * 아 서로소 체크 저것도 있었군 == 박인서 == * 최대공약수를 a, 최소공배수를 b라 하면 b=a*x*y가 되도록 하면 두 수 a*x와 a*y가 원래의 두 수가 된다. * 이때 x와 y는 자연수여야 되고, 서로소여야한다. * 위의 아이디어를 이용하여 문제를 풀었다. == 곽정흠 ==