T = int(input())
while T:
n = int(input())
a = [int(x) for x in input().split()]
s = 0
if n & 1:
s = 3
if a[0]+a[1] != 0:
print("%d %d %d " % (-a[2], -a[2], a[0]+a[1]), end="")
elif a[0]+a[2] != 0:
print("%d %d %d " % (-a[1], a[0]+a[2], -a[1]), end="")
else:
print("%d %d %d " % (a[1]+a[2], -a[0], -a[0]), end="")
while s < n:
print("%d %d " % (-a[s+1], a[s]), end="")
s += 2
print()
T -= 1
#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int a[N];
void solve()
{
int n;
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
if (n & 1)
{
for (int i = 1; i <= n - 3; i += 2)
{
int g = __gcd(abs(a[i]), abs(a[i + 1]));
cout << a[i + 1] / g << ' ' << -a[i] / g << ' ';
}
if (a[n - 2] == a[n - 1] && a[n - 2] == a[n])
{
cout << "1 1 -2 ";
}
else if (a[n - 2] == a[n - 1])
{
cout << a[n] << " " << a[n] << " " << (-2) * a[n - 2];
}
else if (a[n - 2] == a[n])
{
cout << a[n - 1] << " " << (-2) * a[n - 2] << " " << a[n - 1];
}
else if (a[n - 1] == a[n])
{
cout << (-2) * a[n] << " " << a[n - 2] << " " << a[n - 2];
}
else
{
cout << a[n - 1] - a[n] << " " << a[n] - a[n - 2] << " " << a[n - 2] - a[n - 1];
}
}
else
{
for (int i = 1; i <= n; i += 2)
{
int g = __gcd(abs(a[i]), abs(a[i + 1]));
cout << a[i + 1] / g << ' ' << -a[i] / g << ' ';
}
}
cout << '\n';
}
int main()
{
int t;
cin >> t;
while (t--)
solve();
return 0;
}
1920. Build Array from Permutation | 494. Target Sum |
797. All Paths From Source to Target | 1547B - Alphabetical Strings |
1550A - Find The Array | 118B - Present from Lena |
27A - Next Test | 785. Is Graph Bipartite |
90. Subsets II | 1560A - Dislike of Threes |
36. Valid Sudoku | 557. Reverse Words in a String III |
566. Reshape the Matrix | 167. Two Sum II - Input array is sorted |
387. First Unique Character in a String | 383. Ransom Note |
242. Valid Anagram | 141. Linked List Cycle |
21. Merge Two Sorted Lists | 203. Remove Linked List Elements |
733. Flood Fill | 206. Reverse Linked List |
83. Remove Duplicates from Sorted List | 116. Populating Next Right Pointers in Each Node |
145. Binary Tree Postorder Traversal | 94. Binary Tree Inorder Traversal |
101. Symmetric Tree | 77. Combinations |
46. Permutations | 226. Invert Binary Tree |