当前位置: 首页> 健康> 知识 > 上海十大公司排名_新媒体运营公司排行榜_大连网站建设_长沙正规竞价优化推荐

上海十大公司排名_新媒体运营公司排行榜_大连网站建设_长沙正规竞价优化推荐

时间:2025/7/13 16:06:43来源:https://blog.csdn.net/jj12345jj198999/article/details/146714839 浏览次数:0次
上海十大公司排名_新媒体运营公司排行榜_大连网站建设_长沙正规竞价优化推荐

time limit per test

1 second

memory limit per test

256 megabytes

There are nn teams in a football tournament. Each pair of teams match up once. After every match, Pak Chanek receives two integers as the result of the match, the number of goals the two teams score during the match. The efficiency of a team is equal to the total number of goals the team scores in each of its matches minus the total number of goals scored by the opponent in each of its matches.

After the tournament ends, Pak Dengklek counts the efficiency of every team. Turns out that he forgot about the efficiency of one of the teams. Given the efficiency of n−1n−1 teams a1,a2,a3,…,an−1a1,a2,a3,…,an−1. What is the efficiency of the missing team? It can be shown that the efficiency of the missing team can be uniquely determined.

Input

Each test contains multiple test cases. The first line contains an integer tt (1≤t≤5001≤t≤500) — the number of test cases. The following lines contain the description of each test case.

The first line contains a single integer nn (2≤n≤1002≤n≤100) — the number of teams.

The second line contains n−1n−1 integers a1,a2,a3,…,an−1a1,a2,a3,…,an−1 (−100≤ai≤100−100≤ai≤100) — the efficiency of n−1n−1 teams.

Output

For each test case, output a line containing an integer representing the efficiency of the missing team.

Example

Input

Copy

 

2

4

3 -4 5

11

-30 12 -57 7 0 -81 -68 41 -89 0

Output

Copy

-4
265

Note

In the first test case, below is a possible tournament result:

  • Team 11 vs. Team 22: 1−21−2
  • Team 11 vs. Team 33: 3−03−0
  • Team 11 vs. Team 44: 3−23−2
  • Team 22 vs. Team 33: 1−41−4
  • Team 22 vs. Team 44: 1−31−3
  • Team 33 vs. Team 44: 5−05−0

The efficiency of each team is:

  1. Team 11: (1+3+3)−(2+0+2)=7−4=3(1+3+3)−(2+0+2)=7−4=3
  2. Team 22: (2+1+1)−(1+4+3)=4−8=−4(2+1+1)−(1+4+3)=4−8=−4
  3. Team 33: (0+4+5)−(3+1+0)=9−4=5(0+4+5)−(3+1+0)=9−4=5
  4. Team 44: (2+3+0)−(3+1+5)=5−9=−4(2+3+0)−(3+1+5)=5−9=−4

Therefore, the efficiency of the missing team (team 44) is −4−4.

It can be shown that any possible tournament of 44 teams that has the efficiency of 33 teams be 33, −4−4, and 55 will always have the efficiency of the 44-th team be −4−4.

解题说明:水题,能发现得分总和必须要为0,直接求和找出丢失的数字即可。

#include <bits/stdc++.h>
#include<iostream>
using namespace std;void solve()
{int n;cin >> n;int sum = 0;for (int i = 0; i < n - 1; i++){int temp;cin >> temp;sum += temp;}cout << -(sum) << endl;
}int main()
{int T = 1;cin >> T;while (T--){solve();}return 0;
}

关键字:上海十大公司排名_新媒体运营公司排行榜_大连网站建设_长沙正规竞价优化推荐

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: