time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

An array bb of length kk is called good if its arithmetic mean is equal to 11. More formally, if

b1+⋯+bkk=1.b1+⋯+bkk=1.

Note that the value b1+⋯+bkkb1+⋯+bkk is not rounded up or down. For example, the array [1,1,1,2][1,1,1,2] has an arithmetic mean of 1.251.25, which is not equal to 11.

You are given an integer array aa of length nn. In an operation, you can append a non-negative integer to the end of the array. What's the minimum number of operations required to make the array good?

We have a proof that it is always possible with finitely many operations.

Input

The first line contains a single integer tt (1≤t≤10001≤t≤1000) — the number of test cases. Then tt test cases follow.

The first line of each test case contains a single integer nn (1≤n≤501≤n≤50) — the length of the initial array aa.

The second line of each test case contains nn integers a1,…,ana1,…,an (−104≤ai≤104−104≤ai≤104), the elements of the array.

Output

For each test case, output a single integer — the minimum number of non-negative integers you have to append to the array so that the arithmetic mean of the array will be exactly 11.

Example

input

Copy

4
3
1 1 1
2
1 2
4
8 4 6 2
1
-2

output

Copy

0
1
16
1

Note

In the first test case, we don't need to add any element because the arithmetic mean of the array is already 11, so the answer is 00.

In the second test case, the arithmetic mean is not 11 initially so we need to add at least one more number. If we add 00 then the arithmetic mean of the whole array becomes 11, so the answer is 11.

In the third test case, the minimum number of elements that need to be added is 1616 since only non-negative integers can be added.

In the fourth test case, we can add a single integer 44. The arithmetic mean becomes −2+42−2+42 which is equal to 11.

解题说明:水题,求和判断即可。

#include<stdio.h>int main()
{int n, t, sum = 0, i, k;int a[1001];scanf("%d", &n);for (i = 1; i <= n; i++){scanf("%d", &t);for (k = 1; k <= t; k++){scanf("%d", &a[k]);sum = sum + a[k];}if (sum >= t){printf("%d\n", (sum - t));}if (sum < t){printf("1\n");}sum = 0;}return 0;
}

A. Arithmetic Array相关推荐

  1. A. Arithmetic Array Codeforces Round #726 (Div. 2)

    A. Arithmetic Array An array b of length k is called good if its arithmetic mean is equal to 1. More ...

  2. [CF/AT/Luogu]各大网站网赛 爆肝部部长工作报告文件Ⅱ

    文章目录 CodeForces LATOKEN-Round-1(Div.1+Div.2) A. Colour the Flag B. Histogram Ugliness C. Little Alaw ...

  3. codeforces:ProblemMset

    最近一个月在codeforces上做的题(做个记录) 后面太多了就不把代码一一放出了,只放置了链接,可根据链接找到提交的代码. 最小子矩阵 #include <iostream> #inc ...

  4. Caché 实操《Caché 算法与数据结构-数组原理》学习笔记

    参考书  第二章 Caché 算法与数据结构 数组原理_yaoxin521123的博客-CSDN博客 本人Cache'小白,欢迎指教和交流.本文为学习原作者的代码进行代码重现后的总结精炼.使用数据库: ...

  5. 老男孩上海校区Python面试题

    python面试题 第一章:python基础 数据类型: 1 字典: 1.1 现有字典 dict={'a':24,'g':52,'i':12,'k':33}请按字典中的 value 值进行排序? 1. ...

  6. LeetCode 1027. Longest Arithmetic Sequence--笔试题--C++解法

    LeetCode 1027. Longest Arithmetic Sequence–笔试题–C++解法 LeetCode题解专栏:LeetCode题解 我做的所有的LeetCode的题目都放在这个专 ...

  7. LeetCode - 413. Arithmetic Slices - 含中文题意解释 - O(n) - ( C++ ) - 解题报告

    1.题目大意 A sequence of number is called arithmetic if it consists of at least three elements and if th ...

  8. Arithmetic Slices

    这两天一直复习动态规划,就想到leetcode上刷刷题,easy难度的很少,大部分都是medium和hard.本题是第一道DP类型medium难度的题目,但是用其他的方法比如暴力法也可以求解.首先来看 ...

  9. LeetCode 413. Arithmetic Slices

    题目: A sequence of number is called arithmetic if it consists of at least three elements and if the d ...

最新文章

  1. 05Observer/Event(观察者)模式
  2. c#中与vb中CType相同功能的函数(强类型转换)
  3. 在Axure RP 8.0 中使用 Font Awesome 图标库完成设计并能在其他未安装该字体的电脑离线预览的方法...
  4. Jsp—02—项目:登录案例
  5. 教你用JS手写简单的秒表(精确到10ms,没有延迟)
  6. @select注解_mybatis开发,你用 xml 还是注解?我 pick xml
  7. java 注释添加引用_java – 如何引用注释处理中的方法的实现?
  8. 练习五十一:序列交换
  9. Python MQTT订阅获取发布信息字典过滤
  10. Python 使用pdfplumber直接提取PDF文本内容
  11. 使用springmvc时处理404的方法
  12. jQuery中的read 和JavaScript中 的onload函数的区别
  13. 2021湖南高考成绩分段查询,2021年湖南高考成绩排名查询系统,湖南高考位次排名表...
  14. centos7下扩充swap空间
  15. Android 打aar包
  16. 百度输入法黑莓版更新至1.0.1.7
  17. Spring动态代理中有什么方法不会被代理探究
  18. android中图片压缩上传方法之Luban库
  19. l2tp 账户管理系统
  20. register解析

热门文章

  1. Nature Neuroscience:怀孕导致人类大脑结构的长久改变
  2. SDN和NFV并没有迅速落地的原因是什么?
  3. Java 练习之回合制游戏,练习接口,随机,数组,可变参数
  4. 《中国程序化广告技术生态图》2015年三月号更新发布
  5. CodeForces - 985A Chess Placing(水)
  6. 如何分析和判断中国经济大势
  7. 数字货币智能合约的概念与演变
  8. 峡谷之巅显示服务器更新,峡谷之巅更新最新资讯
  9. 【问题解决】This container is having trouble accessing https://k8s.gcr.io | 如何解决从k8s.gcr.io拉取镜像失败问题?
  10. uc保存html,UC浏览器如何保存网页 怎么保存网页图文教程