日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

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

發布時間:2023/12/10 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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 formally, if
b1+?+bkk=1.
Note that the value b1+?+bkk is not rounded up or down. For example, the array [1,1,1,2] has an arithmetic mean of 1.25, which is not equal to 1.

You are given an integer array a of length n. 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 t (1≤t≤1000) — the number of test cases. Then t test cases follow.

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

The second line of each test case contains n integers a1,…,an (?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 1.

Example
inputCopy
4
3
1 1 1
2
1 2
4
8 4 6 2
1
-2
outputCopy
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 1, so the answer is 0.

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

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

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

#include <bits/stdc++.h> #define int long long using namespace std; const int maxn=1e9+5; int t,n,x; signed main(){cin >> t;while (t--){cin>>n;int sum=0;for(int i=0;i<n;++i){cin>>x;sum+=x;}if(sum<n) cout<<1<<'\n';if(sum==n) cout<<0<<'\n';if(sum>n) cout<<sum-n<<'\n';}}

總結

以上是生活随笔為你收集整理的A. Arithmetic Array Codeforces Round #726 (Div. 2)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 亚洲成人av免费在线观看 | 成人激情站 | 一道本一区二区 | 国产精品久久久午夜夜伦鲁鲁 | 久久精品免费网站 | 午夜性色福利影院 | 婷婷色在线视频 | 91原创视频在线观看 | 国产精品播放 | 精品无码久久久久久久久成人 | 女人脱下裤子让男人捅 | 四虎最新域名 | 国产亚洲一区二区在线 | 国产伦精品一区二区三区高清版禁 | 大桥未久av一区二区三区中文 | 91精品国自产在线观看 | 男人用嘴添女人下身免费视频 | 久草精品在线观看视频 | 日韩偷拍一区 | 国产男女爽爽爽 | 亚洲国产精品福利 | 欧美 日韩 成人 | 不卡一区二区三区四区 | 欧美人体视频一区二区三区 | 开心激情网五月天 | 国产午夜精品久久久久久久 | 99国产精品99久久久久久 | 看黄色小视频 | 一区二区免费在线观看视频 | 能看的av网站 | 成年人黄色录像 | 亚洲av电影天堂男人的天堂 | 免费成人看片 | 久久成人在线视频 | 国产在线视频99 | 中文在线天堂网 | 99精品小视频 | 国产免费内射又粗又爽密桃视频 | 国产精品美女在线 | 中国一级黄色 | 国产麻豆交换夫妇 | 色女人av| 免费的理伦片在线播放 | 久久精品国产露脸对白 | 国产做受高潮漫动 | 一卡二卡三卡在线 | 最新国产黄色网址 | 国产福利视频导航 | 国产欧美精品一区二区色综合朱莉 | 日韩欧美91 | 欧美色图网站 | 欧洲中文字幕日韩精品成人 | 亚洲永久在线 | 自拍偷拍色 | 亚洲精品成 | 中文字幕在线观看日韩 | 亚洲男女视频 | 天天舔天天爽 | 国产污视频网站 | 久久丫精品忘忧草西安产品 | 手机在线观看av片 | 日日碰碰 | 国产精品久久久久不卡 | 日本成人动漫在线观看 | 午夜丁香婷婷 | 亚洲国产精品久久精品怡红院 | 一区二区视频在线观看 | 女人扒开屁股让我添 | av中文字幕av | 香港三级在线视频 | 亚洲素人 | 男女视频一区二区 | aa视频免费观看 | 日韩在线一区二区三区四区 | 99草视频 | 日本一区二区三区在线免费观看 | 黄色同人网站 | 亚洲av电影一区二区 | 无码人妻一区二区三区线 | 日韩tv | 亚洲色中色 | 一级淫片免费看 | 在线观看国产麻豆 | 五月天国产视频 | 国产精品成人自拍 | av在线有码 | 雷电将军和丘丘人繁衍后代视频 | 欧美一级片在线视频 | 色在线免费视频 | 国产又粗又猛又爽免费视频 | 精品人妻伦一区二区三区久久 | 久操视频在线观看免费 | 欧美熟妇精品一区二区蜜桃视频 | 视色影视| 欧美乱大交xxxxx潮喷l头像 | 精品人妻一区二区三区蜜桃 | 人体一级片 | 国产一区美女 | 草草影院在线观看 |