日韩性视频-久久久蜜桃-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)的全部內容,希望文章能夠幫你解決所遇到的問題。

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

主站蜘蛛池模板: 日本黄色不卡视频 | 国产激情视频一区二区三区 | 日韩aⅴ片 | 亚洲av无码精品色午夜果冻不卡 | 国产精品亚洲αv天堂无码 伊人性视频 | 国产乱强伦一区二区三区 | 全球av在线 | 欧美精品一级在线观看 | 午夜精品毛片 | 99久久综合网 | 亚洲色图图片 | av影库 | 亚洲精品一区二区口爆 | 国产一区二区亚洲 | 国产精品伦一区二区三级古装电影 | 人妻精品无码一区二区 | 欧美日韩国产成人在线 | 一区av在线 | 亚洲女优一区 | 久久亚洲av成人无码国产电影 | 国产亚洲欧美精品久久久www | 国产亚洲精久久久久久无码苍井空 | 日韩欧美不卡视频 | 啪啪小视频 | 天堂资源最新在线 | 男人日女人在线观看 | 中文字幕欧美专区 | 丰满人妻一区二区三区免费 | 久久亚洲网 | 国产精品3区 | 国产精品成人av久久 | 69视频免费观看 | 精品国产欧美 | 欧美a级大片 | 美女av毛片 | 99久久99久久精品国产片桃花 | 久久久久亚洲av无码专区体验 | 黄色大片网 | 亚洲免费播放 | 综合久久影院 | 销魂奶水汁系列小说 | 在线观看岛国av | 91超碰在线 | 午夜影院欧美 | 妞妞av| av福利在线观看 | 少妇综合网 | 美女搡bbb又爽又猛又黄www | 综合国产精品 | www.亚洲色图 | 国产在线观看黄 | 久久av色 | 一级黄色免费视频 | 久久久久亚洲av成人无码电影 | 久久久天堂 | 久久草精品 | 天天看毛片 | 丰满岳妇乱一区二区三区 | 伊人久久大香线蕉成人综合网 | 91视频黄版| 国产精品88久久久久久妇女 | 国产午夜亚洲精品午夜鲁丝片 | 少妇av一区 | 天天射寡妇 | 成人av激情 | 日日拍拍 | 黄色a级片在线观看 | 久久久久久av无码免费网站 | 法国少妇愉情理伦片 | 亚洲热热| 国产东北女人做受av | 69视频在线免费观看 | www.黄色国产 | 夜夜夜夜爽| 中文在线观看免费视频 | 爱情岛论坛永久入址测速 | 午夜电影在线播放 | 高潮毛片无遮挡免费看 | 精品一区二区三区成人免费视频 | 国产精品久久久久久久久久久久久久久久久久 | 九九综合 | 人人妻人人做人人爽 | www狠狠| 熟女肥臀白浆大屁股一区二区 | 有码在线视频 | 亚洲天堂色 | 色噜噜狠狠一区二区 | 奇米第四色777 | 成年人在线免费观看视频网站 | 高跟鞋和丝袜猛烈xxxxxx | 亚洲三级图片 | 国产精品嫩草影院桃色 | 欧美a级免费 | 国产精品久久久91 | 男女一区| 国产精品无码免费在线观看 | 国产精品国产三级国产aⅴ中文 | 肥臀浪妇太爽了快点再快点 | 日本高清视频www |