CF BUDDY
← Problems·

1114E · Arithmetic Progression

2200 · binary search, interactive, number theory

Problem: This is an interactive problem!

An arithmetic progression or arithmetic sequence is a sequence of integers such that the subtraction of element with its previous element (xixi1x_i - x_{i - 1}, where i2i \ge 2) is constant — such difference is called a common difference of the sequence.

That is, an arithmetic progression is a sequence of form xi=x1+(i1)dx_i = x_1 + (i - 1) d, where dd is a common difference of the sequence.

There is a secret list of nn integers a1,a2,,ana_1, a_2, \ldots, a_n.

It is guaranteed that all elements a1,a2,,ana_1, a_2, \ldots, a_n are between 00 and 10910^9, inclusive.

This list is special: if sorted in increasing order, it will form an arithmetic progression with positive common difference (d>0d > 0). For example, the list [14,24,9,19][14, 24, 9, 19] satisfies this requirement, after sorting it makes a list [9,14,19,24][9, 14, 19, 24], which can be produced as xn=9+5(n1)x_n = 9 + 5 \cdot (n - 1).

Also you are also given a device, which has a quite discharged battery, thus you can only use it to perform at most 6060 queries of following two types:

  • Given a value ii (1in1 \le i \le n), the device will show the value of the aia_i.
  • Given a value xx (0x1090 \le x \le 10^9), the device will return 11 if an element with a value strictly greater than xx exists, and it will return 00 otherwise.

Your can use this special device for at most 6060 queries. Could you please find out the smallest element and the common difference of the sequence? That is, values x1x_1 and dd in the definition of the arithmetic progression. Note that the array aa is not sorted.

Note: Note that the example interaction contains extra empty lines so that it's easier to read. The real interaction doesn't contain any empty lines and you shouldn't print any extra empty lines as well.

The list in the example test is [14,24,9,19][14, 24, 9, 19].

Sample Cases

Case 1

Input

4

0

1

14

24

9

19

Output

> 25

> 15

? 1

? 2

? 3

? 4

! 9 5

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback