아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Guess the modulo

면접 대비

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

요약
N과 N-1개의 초기 값이 주어질 때, 히든 블랙박스에 질의를 보내 2 이상 10^9 이하인 모듈로 M을 알아내는 문제입니다.
난이도

보통10점 중 7점

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

문제

Fimka Sobak, unlike Ellochka the Cannibal, was reputed to be a cultured girl. In addition to her favorite smart buzzword, the …\ldots-ality, she learned a remarkably entertaining game, "Guess the modulo".

The game is played in the following way. There are two players: the leader and the player. The leader initially thinks of two numbers: NN --- the number of numbers to be summed and MM --- the modulo. The leader tells the player the number NN, and the player must guess the number MM. Moreover, the leader thinks of an array of (N−1)(N-1) numbers and tells it to the player.

During the game the player tells the leader numbers to get more information. Every time the player says a number, the leader:

  1. appends it to the end of his array,
  2. calculate SS --- the sum of the last NN numbers in the array by the modulo MM,
  3. appends SS to the end of the array and
  4. tells SS to the player.

As soon as the player guesses the value of the modulo MM, he or she informs the leader.

It is known that the modulo MM lies within the range between 22 and 10910^9, inclusively.

입력

The first line of the input stream contains a single integer NN (2≤N≤1002 \le N \le 100). The following line contains (N−1)(N-1) space-separated integers ranging from 00 to 10910^9 inclusively.

The following lines of the input stream contain answers to questions. Each answer is the sum of the last NN elements of its array by modulo MM.

출력

You should print the queries and the player's answer into the standard output.

Player query format: "? p", p --- the number added by the player to the array. The number pp must be integer and must lie within the range from 00 to 10910^9 inclusively.

Player answer format: "! M", M --- the modulo in question.

Make sure that each query ends with a line break and that you flush the output stream buffer (the flush command of the language). Otherwise the solution may get the verdict Deadlock.

예제1

  1. 예제 1

    입력
    4
    1 2 3
    6
    0
    6
    
    예상 출력
    ? 0
    ? 5
    ? 2
    ! 7