시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 1 1 1 100.000%

문제

강호는 친구들과 함께 맥주를 먹으면서 다트를 하러왔다.

강호와 친구들은 다트 게임 중 가장 쉬운 게임 중 하나인 501을 한다. 두 플레이어는 N점 점수를 가진 상태로 시작하며, 서로 턴을 번갈아가면서 다트를 던진다. 각 플레이어는 다트로 맞춘 점수만큼 점수가 감소하게 되며, 점수는 음수가 될 수 없다. 만약, 점수가 감소했을 때, 음수가 되어야 하면, 점수는 그대로 유지된다. 두 플레이어 중에서 먼저 0점을 만든 사람이 게임을 승리하게 된다. 아래 그림은 이번 게임에서 사용할 다트판이다.

두 사람 A와 B는 서로 다른 전략을 가지고 게임을 하려고 한다.

A는 다트를 무작위로 던지며, 다트판의 각 칸을 맞출 확률이 모두 같으며, B는 자신이 승리할 확률이 가장 높은 칸을 겨냥해서 다트를 던진다. 이때, B는 겨냥한 칸과 좌우로 인접한 칸만 맞추며, 각각의 칸을 맞출 확률은 같다.

두 플레이어의 초기 점수가 주어졌을 때, 각 플레이어가 이길 확률을 구하는 프로그램을 작성하시오. 누가 다트를 먼저 던지냐에 따라서, 확률이 다르다.

입력

첫째 줄에 초기 점수 N (1 ≤ N ≤ 501)이 주어지며, N = 0인 경우에 입력의 종료를 나타낸다.

출력

각각의 입력에 대해서, A가 다트를 먼저 던졌을 때 이길 확률과 B가 먼저 던졌을 때 이길 확률을 출력한다. 정답과의 절대/상대 오차는 10-8까지 허용한다.

예제 입력 1

5
100
0

예제 출력 1

0.136363636364 0.909090909091
0.072504908290 0.950215081962
W3sicHJvYmxlbV9pZCI6IjM4NTgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIyZTRcdWQyYjgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YWMxNVx1ZDYzOFx1YjI5NCBcdWNlNWNcdWFkNmNcdWI0ZTRcdWFjZmMgXHVkNTY4XHVhZWQ4IFx1YjllNVx1YzhmY1x1Yjk3YyB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