-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path011-67.cpp
More file actions
71 lines (65 loc) · 1.3 KB
/
Copy path011-67.cpp
File metadata and controls
71 lines (65 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
* 67 [106251E]
* Problem: Gym/ICPC contest 106251 - problem E
* Verdict: ACCEPTED Solved: 2026-06-20
* Language: C++20 (GCC 13-64)
* Runtime: 109 ms Memory: 2400 KB
* Tags: n/a
* Author: team "balls" (HossamIsmail, BidoTeima, a1abay)
* Source: https://codeforces.com/gym/106251/submission/379575854
*/
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int sz = 3e5 + 2;
int n, a[sz];
int ask(int i, int j)
{
cout << "? " << i << ' ' << j << endl;
int x;
cin >> x;
return x;
}
void solve()
{
int n;
cin >> n;
int a[n + 1];
for(int i = 1; i <= n - n % 3; i += 3)
{
int x = ask(i, i + 1);
int y = ask(i + 1, i + 2);
a[i + 1] = __gcd(x, y);
a[i] = x / a[i + 1];
a[i + 2] = y / a[i + 1];
}
if(n % 3 == 1)
{
int x = ask(n - 1, n);
a[n] = x / a[n - 1];
}
if(n % 3 == 2)
{
int x = ask(n - 2, n - 1);
a[n - 1] = x / a[n - 2];
x = ask(n - 1, n);
a[n] = x / a[n - 1];
}
cout << "! ";
for(int i = 1; i <= n; i++)
{
cout << a[i] << ' ';
}
cout << endl;
}
signed main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
int t = 1;
cin >> t;
while(t--)
{
solve();
}
}