Link to the problem
import sys
n = int(input())
c1 = 3
c2 = 4
L = [0]*n
sys.stdout.write('? 1 2\n')
sys.stdout.flush()
sum12 = int(input())
sys.stdout.write('? 2 3\n')
sys.stdout.flush()
sum23 = int(input())
sys.stdout.write('? 1 3\n')
sys.stdout.flush()
sum13 = int(input())
L[0] = (sum13 + sum12 - sum23) // 2
L[1] = sum12 - L[0]
L[2] = sum13 - L[0]
if n == 3:
print('!', *L)
else:
n1 = 3
while n1 < n:
b = '? ' + str(c1) + ' ' + str(c2) + '\n'
sys.stdout.write(b)
sys.stdout.flush()
sum34 = int(input())
L[n1] = sum34 - L[n1 - 1]
n1 += 1
c1 += 1
c2 += 1
if n > 3:
print('!', *L)
import sys
n = int(input())
c1 = 3
c2 = 4
L = [0]*n
sys.stdout.write('? 1 2\n')
sys.stdout.flush()
sum12 = int(input())
sys.stdout.write('? 2 3\n')
sys.stdout.flush()
sum23 = int(input())
sys.stdout.write('? 1 3\n')
sys.stdout.flush()
sum13 = int(input())
L[0] = (sum13 + sum12 - sum23) // 2
L[1] = sum12 - L[0]
L[2] = sum13 - L[0]
if n == 3:
print('!', *L)
else:
n1 = 3
while n1 < n:
b = '? ' + str(c1) + ' ' + str(c2) + '\n'
sys.stdout.write(b)
sys.stdout.flush()
sum34 = int(input())
L[n1] = sum34 - L[n1 - 1]
n1 += 1
c1 += 1
c2 += 1
if n > 3:
print('!', *L)
Комментариев нет:
Отправить комментарий