SPOJ - MKEQUAL E - Make them equal ! 水题
来源:互联网 发布:磁铁车牌号码贴 淘宝 编辑:程序博客网 时间:2024/06/16 20:54
You have an array containing N elements. At any move, you choose two indices i and j ( 0 <= i, j < N and i != j ) and increment value at one index and decrement value at other index. You can make this move any number of times. What is the maximum number of elements which can have the same value (after any number of moves) ?
Input
First line consists of T, the number of test cases. (1 <= T <= 100)
T sets follow. Each set contains N, the number of elements in the array, in the first line. (1 <= N <= 100000)
Next line of each set consists of N space separated integers (0 <= value <= 100000)
Output
Output T lines each containing the required answer.
Example
Input:141 2 3 4Output: 3
水题,,判断和是否被n整除
#include <iostream> #include <cstdio>#include <cstdlib>#include <cmath>#include <fstream>#include <algorithm>#include <climits>#include <cstring>#include <string>#include <set>#include <map>#include <queue>#include <stack>#include <vector>#include <list>const int maxn=5e2+10;using namespace std;typedef long long ll;typedef unsigned long long ull; int T;int n;ll sum =0;ll t;int main(){cin >> T;while(T--){cin >>n;int t1 = n;while(t1--){cin >>t;sum+=t;}if(sum%n==0){cout << n<<endl;}elsecout << n-1<<endl;}return 0;}
0 0
- SPOJ - MKEQUAL E - Make them equal ! 水题
- SPOJ Make them equal !
- 数论 make them equal!
- SPOJ QUEST5 Nail Them
- Nail Them+SPOJ+贪心算法
- SPOJ TRNGL - Make Triangle
- [SPOJ INS14G Kill them All]数学、排列组合
- make 报错 make e=234
- Oracle's new plan: Make friends, don't buy them
- Sparse Dictionaries (How to Make or Find them)
- SPOJ 130 Rent your airplane and make money
- SPOJ TRNGL Make Triangle && CodeForces 550D Regular Bridge
- Make Triangle SPOJ - TRNGL (卡特兰数)
- 【leetcode】453. Minimum Moves to Equal Array Elements【E】
- equal
- equal
- SPOJ
- SPOJ
- @Profile的使用
- 年终总结
- Android Studio中创建JAVA应用程序步骤
- 微信小程序初探
- 【H.264/AVC视频编解码技术详解】十二、解析H.264码流的宏块结构(下):H.264帧内编码宏块的预测结构
- SPOJ - MKEQUAL E - Make them equal ! 水题
- 多线程异步任务
- 本地Apache服务器访问时502 Server dropped connection 错误解决方法
- 定时任务
- SpringMVC和 Struts2的比较
- @Conditional条件注解
- 打包成war
- codeforces Good Bye 2016
- 优雅编程之阿里巴巴开发规范分享及扩展学习(三十八)