Shall We Play a Game?

시간 제한2초메모리 제한1024 MB

요약
x에 대한 질문마다 floor(n/x)/n을 기약분수로 받아 숨겨진 양의 정수 n을 알아낸다.
난이도

보통10점 중 7점

유형
정수론, 수학, 이분 탐색, 구현
정답자
아직 제출이 없습니다

문제

This is an interactive problem.

1804. Vice-president of the United States of America Aaron Burr challenged gubernatorial race candidate Alexander Hamilton for writing several offending pamphlets.

But Burr is sane enough to understand that, even if he kills Hamilton, he will lose his reputation and ruin his career. So, the enemies decided to simply play a game. To make everything more fair they decided to play it gg times.

Each game starts with Hamilton thinking up a positive integer nn, and after that Burr tries to guess it. For any positive integer xx Burr may ask Hamilton about fraction of numbers between 11 and nn inclusive that are divisible by xx. In the other words, when asks a question about xx, he receives the value of ⌊nx⌋n.\frac{\left\lfloor\frac{n}{x}\right\rfloor}{n}. Important detail is that Hamilton reports the answer to Burr as an irreducible fraction (here ⌊r⌋\left\lfloor r \right\rfloor denotes the integral part of rr).

Help Burr find the answer using some certain number of queries.

힌트

In the first sample case g=2g = 2. The example queries are listed above, using results of these queries player may understand that in the first game the answer is 1010, and in the second game the answer is 11.

Strictly follow the output format. After printing anything make sure to print a new line and to flush the output buffer, in order to do that you may use flush(output) for Pascal/Delphi, fflush(stdout) or cout.flush() for C/C++, sys.stdout.flush() for Python, System.out.flush() for Java.

예제1

  1. 예제 1

    입력
    2
    
    1 2
    
    3 10
    
    1 5
    
    1 5
    
    1 10
    
    1 10
    
    0 1
    
    Correct
    
    1 1
    
    0 1
    
    Correct
    
    예상 출력
    
    X 2
    
    X 3
    
    X 5
    
    X 4
    
    X 6
    
    X 10
    
    X 11
    
    N 10
    
    X 1
    
    X 2
    
    N 1