Cinderella is given a task by her Stepmother before she is allowed to go to the Ball. There are N (1 ≤ N ≤ 1000) bottles with water in the kitchen. Each bottle contains Li (0 ≤ Li ≤ 10^6) ounces of water and the maximum capacity of each is 109 ounces. To complete the task Cinderella has to pour the water between the bottles to fill them at equal measure.

Cinderella asks Fairy godmother to help her. At each turn Cinderella points out one of the bottles. This is the source bottle. Then she selects any number of other bottles and for each bottle specifies the amount of water to be poured from the source bottle to it. Then Fairy godmother performs the transfusion instantly.

Please calculate how many turns Cinderella needs to complete the Stepmother's task.
Input

The first line of input contains an integer number N (1 ≤ N ≤ 1000) — the total number of bottles.

On the next line integer numbers Li are contained (0 ≤ Li ≤ 10^6) — the initial amount of water contained in ith bottle.
Output

Output a single line with an integer S — the minimal number of turns Cinderella needs to complete her task.

Sample Input
Input
3
5 7 7
Output
2
Input
3
21 10 2012
Output
1
Input
1
100
Output

0

题目意思是给你n个瓶子,每个瓶子中的水量都不一定,每次可以任选一个瓶子给别的瓶子倒任意量的水,问你要使每个瓶子里的水量一样需要的最少倒水次数

这是一道简单数学题,先求水量的平均数,只有比平均水量高的瓶子才能倒水,一个循环遍历即可得出结果

代码如下:

#include <stdio.h>
double p[1001];
int main()
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        double a=0,b;
        for(int i=1;i<=n;i++)
        {
            scanf("%lf",&p[i]);
            a=p[i]+a;
        }
        b=a/n;
        int jishu=0;
        for(int i=1;i<=n;i++)
            if(p[i]>b)
                jishu+=1;
        printf("%d\n",jishu);
    }
    return 0;
}

弱校联萌十一大决战之如日中天-C. Cinderella相关推荐

  1. 弱校联萌十一大决战之如日中天C Cinderella

    Input/Output: standard input/output Cinderella is given a task by her Stepmother before she is allow ...

  2. 弱校联萌十一大决战之如日中天A Ariel【二进制+排序】

    这个题也是太不好懂了==看了过的代码才明白(⊙﹏⊙)b 不过当时就能想到二进制也挺欣慰的 什么叫做"相同的必须有,没有的必须没有,其他的无所谓?"==>后来查询中的给的特征与 ...

  3. 联萌十一大决战之如日中天 C. Cinderella(灰姑娘新编)

    [题目链接] (http://www.bnuoj.com/v3/contest_show.php?cid=6867#problem/C) 题目描述: C. Cinderella Time Limit: ...

  4. 2016弱校联萌十一专场10.2

    F.floyd-warshell 20000个点,距离为1的所有边求最短路 感觉就是单纯的生成树求最短路(最近公共祖先) 然后把去掉的边还原 把涉及的点bfs一下拼出最短路 赛场注意不要被这种题目吓到 ...

  5. [弱校联萌2016]2016弱校联盟十一专场10.2

    比赛链接:https://www.bnuoj.com/v3/contest_show.php?cid=8520 A.无非两种情况,点在体里和点在体外.在体外分三种情况,分别是到顶点的距离最小.到棱的距 ...

  6. [弱校联萌2016]2016弱校联盟十一专场10.3

    比赛链接:https://www.bnuoj.com/v3/contest_show.php?cid=8504#info A.找两个数乘积是连续上升并且最大的. 1 #include <bits ...

  7. [弱校联萌2016]2016弱校联盟十一专场10.5

    比赛链接:https://www.bnuoj.com/v3/contest_show.php?cid=8506#info I.裸数位dp,dp[l][pre][dir][fz]表示长度为l的时候上一个 ...

  8. 河南省多校联萌-HAUT-1285-军团再临

    问题 G: 军团再临 时间限制: 1 秒   内存限制: 128 MB 提交: 48   解决: 19 提交  状态 题目描述 燃烧军团大举入侵艾泽拉斯,现以在艾星建立了大量的军事要塞,这些要塞通过若 ...

  9. zzuli2181-GJJ的日常之暴富梦-多校联萌(四)

    传送门:https://acm.zzuli.edu.cn/zzuliacm/problem.php?id=2181 2181: GJJ的日常之暴富梦 Time Limit: 1 Sec   Memor ...

最新文章

  1. EditPlus集成Java编译和运行命令组建轻量级Java SE开发工具
  2. 世界上将出现一种新职业
  3. pku3176--Cow Bowling
  4. curl的安装与简单使用
  5. PWN-PRACTICE-BUUCTF-28
  6. 自己动手,实现一种类似ListT的数据结构(二)
  7. 计算机x线影像ppt,计算机X线摄影ppt课件
  8. freeswitch 用户配置详解_FreeSwitch安装配置记录-阿里云开发者社区
  9. HDU6322 Problem D. Euler Function【欧拉函数+数学规律】
  10. 通过对极几何求解相机运动
  11. milvus入门学习
  12. 加快pip下载的速度---镜像
  13. 3DS MAX 基础知识 材质编辑器
  14. matlab 数组 冒号,matlab中冒号的用法
  15. PWM 实现调光——测试pwn的功能
  16. 树莓派实现简单的人脸识别
  17. 大江东去浪涛尽,千古风流人物故垒西边。
  18. 空间分析 | 莫兰指数的计算
  19. CVPR 2022 | 重新审视池化:你的感受野不是最理想的
  20. Unity3D找不到UI包的处理方法

热门文章

  1. requireJs快速上手
  2. jQuery中on和trigger的使用
  3. 学富五车的你,敢来迎战Python开发的成语接龙游戏吗?
  4. 2、Prism的使用一
  5. 发那科机器人控制柜示教器不通电_FANUC发那科机器人示教器A05B-2301-C305液晶屏维修...
  6. 联想一体机电源键不亮,一体机电脑按下主机电源开关无法开机的解决方案
  7. Beta冲刺-第一天
  8. RASA3.0-实现FAQ和chitchat功能
  9. 软件工程导论张海蕃书籍pdf_《软件工程导论》张海蕃 课后习题答案.docx
  10. 速上谷歌地图数据管理软件操作图文教程