시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB100940832439.273%

문제

다음과 같은 귀납적인 규칙에 의해서 만들어지는 무한한 크기의 이진 트리를 생각하자. 각각의 노드에는 두 정수의 순서쌍이 할당되어 있다.

  1. 루트에는 (1, 1)이 할당된다.
  2. 어떤 노드가 (a, b)가 할당되었을 때, 그 노드의 왼쪽 자식에는 (a+b, b)가 할당되고, 오른쪽 자식에는 (a, a+b)가 할당된다.

우리는 어떤 노드가 주어졌을 때, 루트에서 그 노드로 이동하는 최단 경로를 찾으려 한다. 하지만 최단 경로가 매우 길 수도 있기 때문에, 왼쪽 자식으로 이동하는 회수와 오른쪽 자식으로 이동하는 회수를 찾으려고 한다.

입력으로 두 정수 A, B가 주어졌을 때, 루트에서 (A, B)가 할당된 노드까지 최단 경로로 이동할 때, 왼쪽 자식으로 이동하는 회수와 오른쪽 자식으로 이동하는 회수를 구해내는 프로그램을 작성하시오.

입력

첫째 줄에 두 정수 A, B(1 ≤ A, B ≤ 2,000,000,000)가 주어진다. 잘못된 입력은 주어지지 않는다고 가정한다.

출력

첫째 줄에 두 정수 L, R을 출력한다. 각각은 왼쪽으로 이동한 회수, 오른쪽으로 이동한 회수를 나타낸다.

예제 입력 1

3 4

예제 출력 1

2 1
W3sicHJvYmxlbV9pZCI6IjIwNzgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWJiMzRcdWQ1NWNcdWM3NzRcdWM5YzRcdWQyYjhcdWI5YWMiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YjJlNFx1Yzc0Y1x1YWNmYyBcdWFjMTlcdWM3NDAgXHVhZGMwXHViMGE5XHVjODAxXHVjNzc4IFx1YWRkY1x1Y2U1OVx1YzVkMCBcdWM3NThcdWQ1NzRcdWMxMWMgXHViOWNjXHViNGU0XHVjNWI0XHVjOWMwXHViMjk0IFx1YmIzNFx1ZDU1Y1x1ZDU1YyBcdWQwNmNcdWFlMzBcdWM3NTggXHVjNzc0XHVjOW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