Toggle menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

1R/2016 09 15

From ZeroWiki
Revision as of 14:46, 26 March 2026 by Maintenance script (talk | contribs) (Repair pages found by live-compare batch 0001)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

오늘의 문제

  • [1]
  • 추석이니 쉬운 문제로..

참가자

  • 미시행

코드

15이원준

#include<iostream>
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<<endl;
}

박인서

#include <iostream>

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는 자연수여야 되고, 서로소여야한다.
  • 위의 아이디어를 이용하여 문제를 풀었다.

곽정흠