Problem:
Problem B: Canceling Sequence
Problem
1以上の整数からなる、長さ $N$ の数列 $A_1, \ldots , A_N$ が与えられます。
以下の条件を満たす数列 $B_1, \ldots , B_N$ を出力してください。
$B_i$は $0$ でない整数である。
$-10^9 ≤ B_i≤ 10^9$
$A_1\times B_1 + \ldots + A_N\times B_N = 0$
Constraints
入力は以下の条件を満たす。
$2 ≤ N ≤ 2 \times 10^5$
$1 ≤ A_i ≤ 1000$
入力は全て整数である。
Input
入力は以下の形式で標準入力から与えられる。
$N$
$A_1$ $A_2$ $\ldots$ $A_N$
Output
条件を満たす数列 $B_1, \ldots , B_N$ を空白区切りで出力してください。
条件を満たす限り、どのような数列を出力しても構いません。
なお、制約の項で記述される条件のもとで、このような数列は必ず存在することが証明できます。
また、末尾に改行を出力するのを忘れないようにしてください。
Sample Input 1
4
1 2 4 4
Sample Output 1
4 -2 -2 2
他に、$\{2,-1,-1,1\}$ などの数列も正解となります。
Sample Input 2
6
5 3 4 7 3 6
Sample Output 2
1 -1 -1 -1 1 1

Submitted solutions:

code_snippet: #include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
    int N;
    cin>>N;
    vector<int> A(N),B(N);
    for(int &i:A)cin>>i;
    if(N%2==0){
        for(int i=0;i<N;i+=2)B[i]=A[i+1],B[i+1]=-A[i];
    }else{
        for(int i=0;i+3<N;i+=2)B[i]=A[i+1],B[i+1]=-A[i];
        B[N-3]=-A[N-2]-A[N-1];
        B[N-2]=B[N-1]=A[N-3];
    }
    for(int i=0;i<N;i++)cout<<B[i]<<(i==N-1?'\n':' ');
}
accuracy: 1
time_ms: 30
memory_kb: 6244
final_rank: 18

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
    int N,Z=0;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i!=N-1)Z+=A[i];
    }
    for(int i=0;i<N;i++)cout<<(i!=N-1?A[N-1]:-Z)<<(i==N-1?"\n":" ");
}
accuracy: 1
time_ms: 30
memory_kb: 3892
final_rank: 7

code_snippet: // competitive-verifier: PROBLEM
#ifdef ATCODER
#pragma GCC target("sse4.2,avx512f,avx512dq,avx512ifma,avx512cd,avx512bw,avx512vl,bmi2")
#endif
#pragma GCC optimize("Ofast,fast-math,unroll-all-loops")
#include <bits/stdc++.h>
#ifndef ATCODER
#pragma GCC target("sse4.2,avx2,bmi2")
#endif
template <class T, class U>
constexpr bool chmax(T &a, const U &b) {
    return a < (T)b ? a = (T)b, true : false;
}
template <class T, class U>
constexpr bool chmin(T &a, const U &b) {
    return (T)b < a ? a = (T)b, true : false;
}
constexpr std::int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr double EPS = 1e-7;
constexpr double PI = 3.14159265358979323846;
#define FOR(i, m, n) for (int i = (m); i < int(n); ++i)
#define FORR(i, m, n) for (int i = (m)-1; i >= int(n); --i)
#define FORL(i, m, n) for (int64_t i = (m); i < int64_t(n); ++i)
#define rep(i, n) FOR (i, 0, n)
#define repn(i, n) FOR (i, 1, n + 1)
#define repr(i, n) FORR (i, n, 0)
#define repnr(i, n) FORR (i, n + 1, 1)
#define all(s) (s).begin(), (s).end()
struct Sonic {
    Sonic() {
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
        std::cout << std::fixed << std::setprecision(20);
    }
    constexpr void operator()() const {}
} sonic;
using namespace std;
using ll = std::int64_t;
using ld = long double;
template <class T, class U>
std::istream &operator>>(std::istream &is, std::pair<T, U> &p) {
    return is >> p.first >> p.second;
}
template <class T>
std::istream &operator>>(std::istream &is, std::vector<T> &v) {
    for (T &i : v) is >> i;
    return is;
}
template <class T, class U>
std::ostream &operator<<(std::ostream &os, const std::pair<T, U> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}
template <class T>
std::ostream &operator<<(std::ostream &os, const std::vector<T> &v) {
    for (auto it = v.begin(); it != v.end(); ++it) os << (it == v.begin() ? "" : " ") << *it;
    return os;
}
template <class Head, class... Tail>
void co(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cout << head << '\n';
    else std::cout << head << ' ', co(std::forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head &&head, Tail &&...tail) {
    if constexpr (sizeof...(tail) == 0) std::cerr << head << '\n';
    else std::cerr << head << ' ', ce(std::forward<Tail>(tail)...);
}
void Yes(bool is_correct = true) { std::cout << (is_correct ? "Yes\n" : "No\n"); }
void No(bool is_not_correct = true) { Yes(!is_not_correct); }
void YES(bool is_correct = true) { std::cout << (is_correct ? "YES\n" : "NO\n"); }
void NO(bool is_not_correct = true) { YES(!is_not_correct); }
void Takahashi(bool is_correct = true) { std::cout << (is_correct ? "Takahashi" : "Aoki") << '\n'; }
void Aoki(bool is_not_correct = true) { Takahashi(!is_not_correct); }
int main(void) {
    int n;
    cin >> n;
    vector<ll> a(n);
    cin >> a;
    ll m = *min_element(all(a));
    vector<ll> ans(n);
    bool f = true;
    rep (i, n) {
        if (a[i] == m && f) {
            f = false;
            continue;
        }
        if (a[i] % m != 0)
            ans[i] = m;
        else
            ans[i] = 1;
    }
    ll s = 0;
    rep (i, n) {
        s += a[i] * ans[i];
    }
    rep (i, n) {
        if (ans[i] == 0)
            ans[i] = -s / m;
    }
    co(ans);
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 6188
final_rank: 10

code_snippet: #include <bits/stdc++.h>


using namespace std;
//make -f ../makefile SRC=
/*
*/


//------------------------------------------------------------------------------
bool DEBUG = false;
const int INF = 1000000000;

const int MAX_N = 200000;
static int vect[MAX_N];

//------------------------------------------------------------------------------
void solve3(int x1, int x2, int x3)
{
    printf("%d %d %d\n", -x3, -x3, x1+x2);
}

// N >= 2
void solve(int N)
{
    //--------------------------------------------------------------------------
    // base cases:
    if (N == 2)
    {
        printf("%d %d\n", -vect[1], vect[0]);
        return;
    }
    else if (N == 3)
    {
        solve3(vect[0], vect[1], vect[2]);
        return;
    }
    //--------------------------------------------------------------------------
    // init:
    //--------------------------------------------------------------------------
    // compute:
    if (N%2 == 1)
    {
        for (int i=0; i<N-3; i+=2) printf("%d %d ", -vect[i+1], vect[i]);
        solve3(vect[N-3], vect[N-2], vect[N-1]);
        return;
    }    

    for (int i=0; i<N-2; i+=2) printf("%d %d ", -vect[i+1], vect[i]);
    printf("%d %d\n", -vect[N-1], vect[N-2]);
}

//------------------------------------------------------------------------------
void test()
{

}

//------------------------------------------------------------------------------
int main()
{
    //test(); return 0;
    //DEBUG = true;
    //--------------------------------------------------------------------------
    int N, num;
    num = scanf("%d ", &N);
    for (int i=0; i<N; ++i) num = scanf("%d ", &vect[i]);
    solve(N);
    //--------------------------------------------------------------------------
    return 0;
}
//------------------------------------------------------------------------------
accuracy: 1
time_ms: 10
memory_kb: 4344
final_rank: 3

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
    int N,Z=0;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i!=N-1)Z+=A[i];
    }
    for(int i=0;i<N;i++)cout<<(i!=N-1?A[N-1]:-Z)<<(i==N-1?"\n":" ");
}
accuracy: 1
time_ms: 30
memory_kb: 3872
final_rank: 6

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    vector<int> A(N);
    int Z=0;
    for(int i=0;i<N;i++){
        cin>>A[i];
        if(i!=N-1)Z+=A[i];
    }

    for(int i=0;i<N;i++)cout<<(i!=N-1?A[N-1]:-Z)<<(i==N-1?"\n":" ");
}
accuracy: 1
time_ms: 10
memory_kb: 3884
final_rank: 2

code_snippet: #include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int N;
    cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int Z=0;
    for(int i=0;i<N;i++){
        if(i==N-1){
            cout<<-Z<<endl;
        }
        else{
            cout<<A[N-1]<<" ";
            Z+=A[i];
        }
    }

}
accuracy: 1
time_ms: 10
memory_kb: 3876
final_rank: 1

code_snippet: /* -*- coding: utf-8 -*-
 *
 * 3152.cc: Problem B: Canceling Sequence
 */

#include<cstdio>
#include<algorithm>
 
using namespace std;

/* constant */

const int MAX_N = 200000;

/* typedef */

typedef long long ll;

/* global variables */

int as[MAX_N], bs[MAX_N];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  if (! (n & 1))
    for (int i = 0; i < n; i += 2)
      bs[i] = as[i + 1], bs[i + 1] = -as[i];
  else {
    bs[0] = bs[1] = as[2], bs[2] = -(as[0] + as[1]);
    for (int i = 3; i < n; i += 2)
      bs[i] = as[i + 1], bs[i + 1] = -as[i];
  }

  for (int i = 0; i < n; i++)
    printf("%d%c", bs[i], (i + 1 < n) ? ' ' : '\n');

  if (false) {
    ll sum = 0;
    for (int i = 0; i < n; i++) sum += as[i] * bs[i];
    printf("sum=%lld\n", sum);
  }

  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 4516
final_rank: 5

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    vector<int> ans(n);
    if(n%2==0){
        for(int i=0; i<n; i+=2){
            ans[i] = a[i+1];
            ans[i+1] = -a[i];
        }
    }else{
        ans[0] = a[2];
        ans[1] = a[2];
        ans[2] = -(a[0]+a[1]);
        for(int i=3; i<n; i+=2){
            ans[i] = a[i+1];
            ans[i+1] = -a[i];
        }
    }
    for(int i=0; i<n-1; i++){
        cout << ans[i] << " ";
    }
    cout << ans.back() << endl;
    return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 4664
final_rank: 12

code_snippet: #include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;


#define SIZE 200005

int table[SIZE];

int main(){

	int N;
	scanf("%d",&N);

	int sum = 0;

	for(int i = 0; i < N; i++){

		scanf("%d",&table[i]);
		if(i < N-1){
			sum += table[i];
		}
	}

	printf("%d",table[N-1]);
	for(int i = 1; i < N-1; i++){

		printf(" %d",table[N-1]);
	}
	printf(" %d\n",-sum);

	return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3984
final_rank: 4

code_snippet: #include <bits/stdc++.h>
using namespace std;
using LL = long long int;
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); i++)
#define incIX(i, l, r) for(LL i = (l)    ; i <  (r); i++)
#define incXI(i, l, r) for(LL i = (l) + 1; i <= (r); i++)
#define incXX(i, l, r) for(LL i = (l) + 1; i <  (r); i++)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); i--)
#define decIX(i, l, r) for(LL i = (r) - 1; i >= (l); i--)
#define decXI(i, l, r) for(LL i = (r)    ; i >  (l); i--)
#define decXX(i, l, r) for(LL i = (r) - 1; i >  (l); i--)
#define inc(i, n)  incIX(i, 0, n)
#define dec(i, n)  decIX(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec1(i, n) decII(i, 1, n)
auto inII = [](auto x, auto l, auto r) { return (l <= x && x <= r); };
auto inIX = [](auto x, auto l, auto r) { return (l <= x && x <  r); };
auto inXI = [](auto x, auto l, auto r) { return (l <  x && x <= r); };
auto inXX = [](auto x, auto l, auto r) { return (l <  x && x <  r); };
auto setmin   = [](auto & a, auto b) { return (b <  a ? a = b, true : false); };
auto setmax   = [](auto & a, auto b) { return (b >  a ? a = b, true : false); };
auto setmineq = [](auto & a, auto b) { return (b <= a ? a = b, true : false); };
auto setmaxeq = [](auto & a, auto b) { return (b >= a ? a = b, true : false); };
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define FR front()
#define BA back()
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define RV(c) reverse(ALL(c))
#define SC static_cast
#define SI(c) SC<int>(c.size())
#define SL(c) SC<LL >(c.size())
#define RF(e, c) for(auto & e: c)
#define SF(c, ...) for(auto & [__VA_ARGS__]: c)
#define until(e) while(! (e))
#define if_not(e) if(! (e))
#define ef else if
#define UR assert(false)
auto * IS = & cin;
auto * OS = & cout;
array<string, 3> SEQ = { "", " ", "" };
// input
template<typename T> T in() { T a; (* IS) >> a; return a; }
// input: tuple
template<int I, typename U> void tin_(istream & is, U & t) {
	if constexpr(I < tuple_size<U>::value) { is >> get<I>(t); tin_<I + 1>(is, t); }
}
template<typename ... T> istream & operator>>(istream & is, tuple<T ...> & t) { tin_<0>(is, t); return is; }
template<typename ... T> auto tin() { return in<tuple<T ...>>(); }
// input: array
template<typename T, size_t N> istream & operator>>(istream & is, array<T, N> & a) { RF(e, a) { is >> e; } return is; }
template<typename T, size_t N> auto ain() { return in<array<T, N>>(); }
// input: multi-dimensional vector
template<typename T> T vin() { T v; (* IS) >> v; return v; }
template<typename T, typename N, typename ... M> auto vin(N n, M ... m) {
	vector<decltype(vin<T, M ...>(m ...))> v(n); inc(i, n) { v[i] = vin<T, M ...>(m ...); } return v;
}
// input: multi-column (tuple<vector>)
template<typename U, int I> void colin_([[maybe_unused]] U & t) { }
template<typename U, int I, typename A, typename ... B> void colin_(U & t) {
	get<I>(t).PB(in<A>()); colin_<U, I + 1, B ...>(t);
}
template<typename ... T> auto colin(int n) {
	tuple<vector<T> ...> t; inc(i, n) { colin_<tuple<vector<T> ...>, 0, T ...>(t); } return t;
}
// output
void out_([[maybe_unused]] string s) { }
template<typename A> void out_([[maybe_unused]] string s, A && a) { (* OS) << a; }
template<typename A, typename ... B> void out_(string s, A && a, B && ... b) { (* OS) << a << s; out_(s, b ...); }
auto outF = [](auto x, auto y, auto z, auto ... a) { (* OS) << x; out_(y, a ...); (* OS) << z << flush; };
auto out  = [](auto ... a) { outF("", " " , "\n", a ...); };
auto outS = [](auto ... a) { outF("", " " , " " , a ...); };
auto outL = [](auto ... a) { outF("", "\n", "\n", a ...); };
auto outN = [](auto ... a) { outF("", ""  , ""  , a ...); };
// output: multi-dimensional vector
template<typename T> ostream & operator<<(ostream & os, vector<T> const & v) {
	os << SEQ[0]; inc(i, SI(v)) { os << (i == 0 ? "" : SEQ[1]) << v[i]; } return (os << SEQ[2]);
}
template<typename T> void vout_(T && v) { (* OS) << v; }
template<typename T, typename A, typename ... B> void vout_(T && v, A a, B ... b) {
	inc(i, SI(v)) { (* OS) << (i == 0 ? "" : a); vout_(v[i], b ...); }
}
template<typename T, typename A, typename ... B> void vout (T && v, A a, B ... b) { vout_(v, a, b ...); (* OS) << a << flush; }
template<typename T, typename A, typename ... B> void voutN(T && v, A a, B ... b) { vout_(v, a, b ...); (* OS)      << flush; }

// ---- ----

int main() {
	auto n = in<int>();
	auto a = vin<int>(n);
	vector<int> ans(n);
	inc(i, n) {
		if(i % 2 == 0 && i + 1 < n) { ans[i] = +a[i + 1]; }
		if(i % 2 == 1             ) { ans[i] = -a[i - 1]; }
	}
	if(n % 2 == 1) {
		auto x = a[n - 3];
		auto y = a[n - 2];
		auto z = a[n - 1];
		ans[n - 3] = y * z;
		ans[n - 2] = x * z;
		ans[n - 1] = -2 * x * y;
	}
	out(ans);
}
accuracy: 1
time_ms: 30
memory_kb: 6256
final_rank: 19

code_snippet: #include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD =  1000000007;
const int INF = 1e11;
using Graph = vector<vector<int>>;

int gcd(int a, int b){
	if(!a) return b;
	return gcd(b%a,a);
}

int lcm(int x, int y){
	if(x == 0 || y==0) return 0;
	return x/gcd(x, y) *y;
}

signed main(){
  int N;
  cin >> N;

  vector<int> A(N);
  int sum = 0;
  for( int i = 0; i < N; i++ ){
    cin >> A[i];
    if( i < N-1 ) sum += A[i];
  }

  for( int i = 0; i < N-1; i++ ) cout << -1*A[N-1] << " ";
  cout << sum << endl;
}
accuracy: 1
time_ms: 30
memory_kb: 4688
final_rank: 13

code_snippet: // clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}
// clang-format on

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    vector<int> b(n, -a[n - 1]);
    b[n - 1] = 0;
    rep(i, n - 1) b[n - 1] += a[i];

    rep(i, n) cout << b[i] << " \n"[i == n - 1];
    return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 4428
final_rank: 14

code_snippet: #pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

int main(void){
  int N; cin >> N;
  vector<int> A(N);
  for (auto& ai : A)
    cin >> ai;
  
  vector<int> res(N);
  if (N % 2 == 0){
    for (int i = 0; i < N; i += 2){
      res[i] = A[i + 1];
      res[i + 1] = -A[i];
    }
  }
  else{
    for (int i = 3; i < N; i += 2){
      res[i] = A[i + 1];
      res[i + 1] = -A[i];
    }
    if (A[0] != A[2]){
      res[0] = A[1];
      res[1] = -A[0] + A[2];
      res[2] = -A[1];
    }
    else{
      res[1] = -2 * A[0];
      res[0] = 1;
      res[2] = 2 * A[1] - 1;
    }
  }

  for (int i = 0; i < N; ++i)
    cout << res[i] << (i == N - 1 ? '\n' : ' ');

  return 0;
}
accuracy: 1
time_ms: 40
memory_kb: 4432
final_rank: 15

code_snippet: #include <bits/stdc++.h>
using namespace std;

int n, sum = 0;
vector<long long> a, b;

int main() {
  cin >> n;
  a.resize(n);
  b.resize(n);
  for (auto &p : a) cin >> p;
  for (int i = 0; i < n - 1; ++i) {
    sum += a[i];
    b[i] = a[n - 1];
  }
  b[n - 1] = -sum;
  sum = 0;
  for (int i = 0; i < n; ++i) {
    sum += a[i] * b[i];
    assert(abs(b[i]) <= (long long)(1e9));
  }
  assert(sum == 0);
  for (int i = 0; i < n; ++i) cout << b[i] << " \n"[i == n - 1];
  return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 6188
final_rank: 17

code_snippet: #include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

ll gcd(ll a, ll b){
  if(b<a) swap(a, b);
  ll r = a % b;
  if(r==0) return b;
  while(r!=0) r = a % b, a = b, b = r;
  return a;
}
ll lcm(ll a, ll b){return (a*b)/gcd(a, b);}

int main(){
  ll n;std::cin >> n;
  vll a(n);re(i, n) scanf("%lld", &a[i]);
  vll ans(n);
  if(n%2==0){
    for(int i=0;i<n;i+=2){
      ll l = lcm(a[i], a[i+1]);
      ll lef = l/a[i];
      ll ri = -l/a[i+1];
      ans[i] = lef, ans[i+1] = ri;
    }
  }else{
    for(int i=0;i<n-3;i+=2){
      ll l = lcm(a[i], a[i+1]);
      ll lef = l/a[i];
      ll ri = -l/a[i+1];
      ans[i] = lef, ans[i+1] = ri;
    }
    //last 3
    ll l = lcm(a[n-3], lcm(a[n-2], a[n-1]));
    ans[n-3] = (2*l)/a[n-3];
    ans[n-2] = -l/a[n-2];
    ans[n-1] = -l/a[n-1];
  }
  for(int i=0;i<n;i++) std::cout << ans[i] << (i==n-1?"\n":" ");
}
accuracy: 1
time_ms: 20
memory_kb: 6328
final_rank: 16

code_snippet: #pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
//#define mod 998244353
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline void out(T a){ cout << a << '\n'; }
void YN(bool ok){if(ok) cout << "Yes" << endl; else cout << "No" << endl;}
//void YN(bool ok){if(ok) cout << "YES" << endl; else cout << "NO" << endl;}


const ll INF=1e18;
const int mx=200005;
//wupc

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    V<ll> a(n),b(n);
    cinf(n,a);
    if(n%2==0){
        for(int i=0;i<n;i+=2){
            b[i]=a[i+1];
            b[i+1]=-a[i];
        }
    }else{
        b[2]=-(a[0]*a[1]+a[0]*a[1]);
        b[0]=a[2]*a[1];
        b[1]=a[2]*a[0];
        for(int i=3;i<n;i+=2){
            b[i]=a[i+1];
            b[i+1]=-a[i];
        }
    }
    rep(i,n) cout<<b[i]<<(i==n-1?"":" ");
    cout<<endl;
}
accuracy: 1
time_ms: 10
memory_kb: 6012
final_rank: 8

code_snippet: #include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <iomanip>
#include <numeric>
#include <queue>
#include <string>
#include <map>
#include <fstream>
#include <cassert>
#include <stack>
#include <climits>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <memory>
#include <functional>
#include <cfloat>
constexpr long long int MOD = 1000000007LL;


int main() {
	int n; std::cin >> n;
	std::vector<int> array(n);
	for (auto& a : array) std::cin >> a;
	std::vector<int> result(n);
	for (auto i = 0; i + 1< result.size(); i += 2) {
		result[i] = array[i + 1];
		result[i + 1] = -array[i];
	}
	if ((n & 1) == 1) {
		result[n - 1] = array[n - 2];
		result[n - 2] -= array[n - 1];
	}
	for (auto i = 0; i < n; ++i) {
		if (i > 0) std::cout << ' ';
		std::cout << result[i];
	}
	std::cout << '\n';
}
accuracy: 1
time_ms: 30
memory_kb: 4644
final_rank: 11

code_snippet: #include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)

const long double EPS = 1e-6, PI = acos((long double)-1);

//ここから編集

ll GCD(ll a, ll b){
  return (b == 0)?a:GCD(b, a%b);
}
ll LCM(ll a, ll b){
  return a/GCD(a, b)*b;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(4);

  int N; cin >> N;
  vector<ll> a(N);
  REP(i,N) cin >> a[i];


  if(N%2 == 0){

    vector<int> ans(N);
    for(int i=0; i<N; i+=2){
      ll lcm = LCM(a[i], a[i+1]);
      ans[i] = -lcm/a[i];
      ans[i+1] = lcm/a[i+1];
    }
    REP(i,N){
      if(i) cout << " ";
      cout << ans[i];
    }
    cout << endl;
  }else{

    vector<int> ans(N);
    {
      ans[0] = -1;
      ll lcm = LCM(a[1]+a[0], a[2]);
      ans[0] = -lcm/(a[1]+a[0]);
      ans[1] = -lcm/(a[1]+a[0]);
      ans[2] = lcm/a[2];
    }
    for(int i=3; i<N; i+=2){
      ll lcm = LCM(a[i], a[i+1]);
      ans[i] = -lcm/a[i];
      ans[i+1] = lcm/a[i+1];
    }
    REP(i,N){
      if(i) cout << " ";
      cout << ans[i];
    }
    cout << endl;

  }
}
accuracy: 1
time_ms: 20
memory_kb: 5204
final_rank: 9

code_snippet: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
#include<set>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	LL a,b,c;
	cin>>n;
	vector<LL> v1,vs(n);
	for(i=0;i<n;i++){
		cin>>a;
		v1.push_back(a);
	}
	if(n%2==1){
		a=v1[0]*v1[1]*v1[2];
		for(i=0;i<3;i++){
			vs[i]=a/v1[i];
		}
		vs[0]*=-2;
	}else i=0;
	for(;i<n;i+=2){
		vs[i]=v1[i+1];
		vs[i+1]=-v1[i];
	}
	array_show(vs);
}
accuracy: 1
time_ms: 40
memory_kb: 6452
final_rank: 20