시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
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
W3sicHJvYmxlbV9pZCI6IjM4NTgiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWIyZTRcdWQyYjgiLCJkZXNjcmlwdGlvbiI6IjxwPlx1YWMxNVx1ZDYzOFx1YjI5NCBcdWNlNWNcdWFkNmNcdWI0ZTRcdWFjZmMgXHVkNTY4XHVhZWQ4IFx1YjllNVx1YzhmY1x1Yjk3Yy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