C - Get-Together at Den's

Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u

Description

Advertising for beer and beer-based beverages must not use images of people and animals. Russia's Federal Law “On Advertising”, Ch. 3, Art. 22
Den invited n friends to his home. The friends were glad but first went to Auchan to buy some juice. The ith friend bought ai liters of juice. Then the friends came to Den and sat down to drink the juice. Everybody, including Den, drank the same amount of juice.
When there was no more juice, Misha started complaining about having bought more juice than he had drunk. Den didn't want Misha to get upset, so he took one hundred roubles out of his pocket and gave the money to Misha to compensate him for the juice he had bought but hadn't drunk himself. Then some more of Den's friends started complaining about the same issue. Den had no more money, so he suggested that all the friends who had bought more juice than they had drunk themselves should fairly divide his one hundred roubles between them. How should Den's friends divide the money? Assume that Den paid not only for the juice he had drunk but also for all the juice that had been drunk by the people who hadn't bought it.

Input

The first line contains the number n of Den's friends (2 ≤ n ≤ 100). In the second line you are given the integers a1, …, an (0 ≤ ai ≤ 100) . The sum of all  ai is positive.

Output

Output how much of the one hundred roubles the ith friend should take. Round the amounts down to an integer number of roubles.

Sample Input

input output
3
10 10 10
33 33 33
2
10 0
100 0
 #include <iostream>
#include <string.h>
#include <stdio.h> using namespace std; int main()
{
int t;
double a[];
double sum,avg,sum1;
while(~scanf("%d",&t))
{
sum=,avg=,sum1=;
for(int i=;i<t;i++)
{
cin>>a[i];
sum+=a[i];
}
double avg=sum/(t+1.0);
for(int i=;i<t;i++)
{
if(a[i]-avg>)
{
sum1+=(a[i]-avg);
}
}
for(int i=;i<t;i++)
{
if(i!=)
printf(" ");
if(a[i]-avg>)
printf("%d", (int)((a[i]-avg)/sum1* + 1e-));
///cout << floor(100*b[i]/max+0.0001); 这也是OK的
///printf("%.0lf",(a[i]-avg)/sum1*100 + 1e-5)); 就错 要屎啊
else
printf("");
}
printf("\n");
}
return ;
}

http://vjudge.net/contest/view.action?cid=51142#problem/C 精度转换的一道题。。。的更多相关文章

  1. 8.14比赛j题 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87813#overview

    就我个人来说我觉得这道题其实不用写题解,只是因为做的时候错了一次,如果不是队友细心,我根本会错下去,所以我感觉自己必须强大#include<stdio.h> #include<str ...

  2. 论坛:Error:No result defined for action cn.itcast.oa.view.action.TopicAction and result

    使用了<s:hidden name="forumId" value="#forum.id"/> 可以改为: <s:hidden name=&q ...

  3. https://vjudge.net/contest/321565#problem/C 超时代码

    #include <iostream> #include <cstdio> #include <queue> #include <algorithm> ...

  4. 2015 Multi-University Training Contest 1 hdu 5296 Annoying problem

    Annoying problem Time Limit: 16000/8000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  5. The 2018 ACM-ICPC Asia Qingdao Regional Contest, Online -C:Halting Problem(模拟)

    C Halting Problem In computability theory, the halting problem is the problem of determining, from a ...

  6. 【取对数】【哈希】Petrozavodsk Winter Training Camp 2018 Day 1: Jagiellonian U Contest, Tuesday, January 30, 2018 Problem J. Bobby Tables

    题意:给你一个大整数X的素因子分解形式,每个因子不超过m.问你能否找到两个数n,k,k<=n<=m,使得C(n,k)=X. 不妨取对数,把乘法转换成加法.枚举n,然后去找最大的k(< ...

  7. 【BFS】【最小生成树】Petrozavodsk Winter Training Camp 2018 Day 1: Jagiellonian U Contest, Tuesday, January 30, 2018 Problem G. We Need More Managers!

    题意:给你n个点,点带权,任意两点之间的边权是它们的点权的异或值中“1”的个数,问你该图的最小生成树. 看似是个完全图,实际上有很多边是废的.类似……卡诺图的思想?从读入的点出发BFS,每次只到改变它 ...

  8. 【状压dp】Petrozavodsk Winter Training Camp 2018 Day 1: Jagiellonian U Contest, Tuesday, January 30, 2018 Problem E. Guessing Game

    题意:给你n个两两不同的零一串,Alice在其中选定一个,Bob去猜,每次询问某一位是0 or 1.问你最坏情况下最少要猜几次. f(22...2)表示当前状态的最小步数,2表示这位没确定,1表示确定 ...

  9. 【推导】【单调性】Petrozavodsk Winter Training Camp 2018 Day 1: Jagiellonian U Contest, Tuesday, January 30, 2018 Problem B. Tribute

    题意:有n个数,除了空集外,它们会形成2^n-1个子集,给你这些子集的和的结果,让你还原原来的n个数. 假设原数是3 5 16, 那么它们形成3 5 8 16 19 21 24, 那么第一轮取出开头的 ...

随机推荐

  1. VS2010错误

    1.用VS2010生成C++程序时,链接器工具错误 LNK1123: fatal error LNK1123: failure during conversion to COFF: file inva ...

  2. de4dot破解脱壳新版MaxtoCode源数组长度不足解决办法

    之前在看雪混了4年.NET破解版主,现在转战这里,发现很多人还在玩的是工具类的破解,可以说这里的人都还是皮毛啊 最近很多人问使用de4dot脱壳MaxtoCode有问题,之前写过一个教程,那是工具篇的 ...

  3. 数组转xml格式/xml格式转数组

    数组转xml格式 $arr=array( 'username'=>'huahua', 'password'=>'123456', 'number'=>'15889652911', ) ...

  4. Python之路番外(第二篇):PYTHON基本数据类型和小知识点

    一.基础小知识点 1.如果一行代码过长,可以用续行符 \换行书写 例子 if (signal == "red") and \ (car == "moving") ...

  5. Gazebo: Could not find parameter robot_description on parameter server

    robot_state_publisher looks for the parameter "robot_description" by default. The robot_st ...

  6. 关于xp操作系统下使用VC6++编写的上位机软件在win10中运行的问题

    将代码拷贝到win10操作系统中,在vs2015环境中重新编译即可. 编译生成的exe出现终止时考虑mscomm控件是否注册. 当win10环境64位操作系统时,将以下四个文件放置于C:\Window ...

  7. 2018.11.24 poj2774Long Long Message(后缀数组)

    传送门 实际上可以用后缀自动机秒掉 当然后缀数组也挺好写. 我们将两个字符串接在一起,为了方便中间用一个特殊字符连接. 然后对新字符串求heightheightheight数组. 求出来之后对所有满足 ...

  8. 2018.10.24 NOIP模拟 小 C 的数组(二分+dp)

    传送门 考试自己yyyyyy的乱搞的没过大样例二分+dp二分+dp二分+dp过了606060把我自己都吓到了! 这么说来乱搞跟被卡常的正解比只少101010分? 那我考场不打其他暴力想正解血亏啊. 正 ...

  9. centos firewalld 基本操作【转】

    1.firewalld的基本使用启动: systemctl start firewalld关闭: systemctl stop firewalld查看状态: systemctl status fire ...

  10. 学以致用十六-----Centos7.2编译安装mysql5.6.22

    一.系统环境 二.卸载系统自带的mariadb rpm -qa | grep db rpm -e --nodeps mariadb-libs-5.5.60 rpm -e --nodeps mariad ...