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. 检查mysql是否运行

    netstat -tunple|grep mysql

  2. How to execute sudo command in remote host via SSH

    Question: I have an interactive shell script, that at one place needs to ssh to another machine (Ubu ...

  3. Mysql遇到的坑

    2018-04-09 这个虽然跟粗心有关,但是Mysql没报错是哪般? select sum(play_count) from tb_user_login where user_id = 61 and ...

  4. scrapy爬取网址,进而爬取详情页问题

    1.最容易出现的问题是爬取到的url大多为相对路径,如果直接将爬取到的url进行二次爬取就会出现以下报错: raise ValueError('Missing scheme in request ur ...

  5. DNA计算机及DNA存储

    傅里叶变换到量子水平,可编程元素到原子分子核能,都可以极大的改变有机体(高级有机体都是有寿命的,例如人类),如果可以出现机械体,核能提供能量:并结合类似高级生物大脑的有机体大脑,不断学习进化,甚至优化 ...

  6. Ajax在jQuery中的应用 (4)向jsp提交表单数据

    ajax技术带给我们的是良好的用户体验,同时,使用jquery可以简化开发,提高工作效率. 下面就介绍一下大致的开发步骤. 工具/原料 本文中使用的是 jquery-1.3.2.min.js 方法/步 ...

  7. Windows 8.1 新控件和功能:

    http://msdn.microsoft.com/zh-cn/library/windows/apps/bg182878.aspx#five 将 XAML 树呈现为位图: 适用于 Windows 8 ...

  8. 在RedHat 和 Ubuntu 中配置 Delphi 的Linux开发环境(转)

    原文地址:http://chapmanworld.com/2016/12/29/configure-delphi-and-redhat-or-ubuntu-for-linux-development/ ...

  9. Codeforces 1086 简要题解

    文章目录 A题 B题 C题 D题 E题 传送门 这场比赛原地爆炸了啊!!! 只做了两道. A题 传送门 手贱没关freopenfreopenfreopen于是wawawa了一次,死活调不出错. 题意: ...

  10. poj-1328(贪心+思维)

    题目链接:传送门 思路:找最少有几个点,先求出每个点的覆盖范围,就是一个点最大可以到达的地方是y相同的地方而且直线距离是d, 所以x范围在[x-sqrt(d*d-y*y),x+sqrt(d*d-y*y ...