CF1413A.Finding Sasuke

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Naruto has sneaked into the Orochimaru's lair and is now looking for Sasuke. There are TT rooms there. Every room has a door into it, each door can be described by the number nn of seals on it and their integer energies a1a_1, a2a_2, ..., ana_n. All energies aia_i are nonzero and do not exceed 100100 by absolute value. Also, nn is even.

In order to open a door, Naruto must find such nn seals with integer energies b1b_1, b2b_2, ..., bnb_n that the following equality holds: a1⋅b1+a2⋅b2+...+an⋅bn=0a_{1} \cdot b_{1} + a_{2} \cdot b_{2} + ... + a_{n} \cdot b_{n} = 0. All bib_i must be nonzero as well as aia_i are, and also must not exceed 100100 by absolute value. Please find required seals for every room there.

鸣人潜入了大蛇丸的巢穴,现在正在寻找佐助。巢穴中共有 TT 个房间。每个房间都有一扇门,每扇门可用其上的封印数量 nn 及其整数能量值 a1a_1, a2a_2, ..., ana_n 来描述。所有能量值 aia_i 均非零,且其绝对值不超过 100100;此外,nn 为偶数。

为了打开一扇门,鸣人必须找到 nn 个具有整数能量值 b1b_1, b2b_2, ..., bnb_n 的封印,使得以下等式成立:

a1⋅b1+a2⋅b2+...+an⋅bn=0.a_{1} \cdot b_{1} + a_{2} \cdot b_{2} + ... + a_{n} \cdot b_{n} = 0.

所有 bib_i 也必须非零(与 aia_i 相同),且其绝对值同样不得超过 100100。请为每个房间找出满足要求的封印。

输入格式

The first line contains the only integer TT (1≤T≤10001 \leq T \leq 1000) standing for the number of rooms in the Orochimaru's lair. The other lines contain descriptions of the doors.

Each description starts with the line containing the only even integer nn (2≤n≤1002 \leq n \leq 100) denoting the number of seals.

The following line contains the space separated sequence of nonzero integers a1a_1, a2a_2, ..., ana_n (∣ai∣≤100|a_{i}| \leq 100, ai≠0a_{i} \neq 0) denoting the energies of seals.

第一行包含唯一一个整数 TT(1≤T≤10001 \leq T \leq 1000),表示大蛇丸巢穴中的房间数量。其余各行描述各扇门。

每扇门的描述以一行开头,该行包含唯一一个偶数 nn(2≤n≤1002 \leq n \leq 100),表示封印的数量。

接下来的一行包含由空格分隔的非零整数序列 a1a_1, a2a_2, ..., ana_n(∣ai∣≤100|a_{i}| \leq 100,且 ai≠0a_{i} \neq 0),表示各封印的能量值。

输出格式

For each door print a space separated sequence of nonzero integers b1b_1, b2b_2, ..., bnb_n (∣bi∣≤100|b_{i}| \leq 100, bi≠0b_{i} \neq 0) denoting the seals that can open the door. If there are multiple valid answers, print any. It can be proven that at least one answer always exists.

对于每扇门,输出一个由空格分隔的非零整数序列 b1b_1, b2b_2, ..., bnb_n(满足 ∣bi∣≤100|b_{i}| \leq 100 且 bi≠0b_{i} \neq 0),表示能够打开该门的封印。若存在多个合法答案,输出任意一个即可。可以证明至少存在一个答案。

输入输出样例

  • 输入#1

    2
    2
    1 100
    4
    1 2 3 6

    输出#1

    -100 1
    1 1 1 -1

说明/提示

For the first door Naruto can use energies [−100,1][-100, 1]. The required equality does indeed hold: 1⋅(−100)+100⋅1=01 \cdot (-100) + 100 \cdot 1 = 0.

For the second door Naruto can use, for example, energies [1,1,1,−1][1, 1, 1, -1]. The required equality also holds: 1⋅1+2⋅1+3⋅1+6⋅(−1)=01 \cdot 1 + 2 \cdot 1 + 3 \cdot 1 + 6 \cdot (-1) = 0.

对于第一扇门,鸣人可以使用的能量为 [−100,1][-100, 1]。所要求的等式确实成立:1⋅(−100)+100⋅1=01 \cdot (-100) + 100 \cdot 1 = 0。

对于第二扇门,鸣人可以使用例如能量 [1,1,1,−1][1, 1, 1, -1]。所要求的等式也成立:1⋅1+2⋅1+3⋅1+6⋅(−1)=01 \cdot 1 + 2 \cdot 1 + 3 \cdot 1 + 6 \cdot (-1) = 0。

输入解题思路,AI测评打分。不知道怎么写?

首页