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. 浅谈多重检验校正FDR

    浅谈多重检验校正FDR Posted: 四月 12, 2017  Under: Basic  By Kai  no Comments 例如,在我们对鉴定到的差异蛋白做GO功能注释后,通常会计算一个p值 ...

  2. samtools

    samtools 用法 samtools <command> [options] command 见以下列表, 每个 command 的 options 也不同 dict faidx in ...

  3. CentOS 7安装配置Samba服务器

    CentOS 7安装配置Samba服务器 CentOS 7下Samba服务器安装配置过程笔记. 假设我们有这样一个场景 共享名 路径 权限 SHAREDOC /smb/docs 所有人员包括来宾均可以 ...

  4. servlet 高级知识之Filter

    Filter叫做拦截器, 对目标资源拦截,拦截HTTP请求和HTTP响应,本质是对url进行拦截. 与serlvet不同的是, Filter的初始化是随着服务器启动而启动. 在Filter接口中定义了 ...

  5. Python参数类型

    位置参数 默认参数 可变参数 命名关键字参数 关键字参数 def position_only(a, b): print(a, b) def keyword(a='a', b='b'): print(a ...

  6. Alpha 冲刺 (2/10)

    队名 火箭少男100 组长博客 林燊大哥 作业博客 Alpha 冲鸭鸭! 成员冲刺阶段情况 林燊(组长) 过去两天完成了哪些任务 协调各成员之间的工作 协助前端界面的开发 搭建测试用服务器的环境 完成 ...

  7. BP神经网络的数学常识

    输入数据X1-Xn. 输入层和隐层之间的权Wji 隐层的输入数据为:∑iwjixi 隐层的输出数据为:yj = f(∑iwjixi).其中f(x)= 隐层的输入数据为:∑jwkjyj 隐层的输出数据为 ...

  8. Codeforces Round #543 (Div. 2) D 双指针 + 模拟

    https://codeforces.com/contest/1121/problem/D 题意 给你一个m(<=5e5)个数的序列,选择删除某些数,使得剩下的数按每组k个数以此分成n组(n*k ...

  9. 安装了nodejs后在命令行运行npm报错:Error: Cannot find module 'internal/util/types'

    报错如下图所示: 解决方法:删除目录“C:\Users\wls\AppData\Roaming\npm\node_modules”下的npm文件夹

  10. springboot实现xml传参和返回值

    1.新建maven工程xml-bean-convert pom.xml如下 <?xml version="1.0" encoding="UTF-8"?&g ...