当前位置:网站首页>Haut OJ 1401: praise energy
Haut OJ 1401: praise energy
2022-07-05 05:20:00 【hunziHang】
Problem description :
Tao Bao Liang 11 give the thumbs-up PK Energy gathering was very hot at that time . Just a few days. , Someone knows the secret of win-win cooperation , There are also people who fight in order to cheat praise , A lot of time was wasted for a little money . But anyway , Finally, it's time to divide up the energy of the team . The energy shared by each person is the number of likes that person has contributed to the team ( Proportion of the whole team ) In direct proportion to , The more you contribute , The more energy you get . Suppose a team has 5 personal .
Input :
The first line is the total energy integer of the team n(100<=n<=100000)
The first 2~6 Line is everyone The number of likes contributed to the team x. (0<= x <= 100000)
Output :
Output takes up one line , Output the energy shared by everyone separately ( Rounding down ), Space separates the middle
The sample input :
8000 50 30 10 10 0
Sample output :
4000 2400 800 800 0
Tips :
If two people contribute equal praise , Then they share the same energy value .
Cause analysis :
1. Be careful All contributions 0 The situation of Then divide equally .
2. Contribution points given in the example , Not by pressing 100% Calculated , Just contribute , Just give exactly equal to 100.
Solution :
#include<stdio.h>
#include<math.h>
int main()
{
int n,a[6],s=0,b[6];
int i;
scanf("%d",&n);
for(i=1;i<=5;i++)
{
scanf("%d",&a[i]);
s+=a[i];
}
if(s==0)
for(i=1;i<=5;i++)
b[i]=n/5;
else
for(i=1;i<=5;i++)
b[i]=n*(a[i]*1.0/s);
for(i=1;i<=5;i++)
printf("%d ",b[i]);
}
边栏推荐
- 利用HashMap实现简单缓存
- Magnifying glass effect
- [to be continued] I believe that everyone has the right to choose their own way of life - written in front of the art column
- [merge array] 88 merge two ordered arrays
- 发现一个很好的 Solon 框架试手的教学视频(Solon,轻量级应用开发框架)
- [binary search] 34 Find the first and last positions of elements in a sorted array
- Embedded database development programming (VI) -- C API
- Introduction to memory layout of FVP and Juno platforms
- [转]MySQL操作实战(三):表联结
- On-off and on-off of quality system construction
猜你喜欢
随机推荐
【ES实战】ES上的native realm安全方式使用
National teacher qualification examination in the first half of 2022
Research on the value of background repeat of background tiling
Stm32cubemx (8): RTC and RTC wake-up interrupt
[allocation problem] 135 Distribute candy
Download and use of font icons
Listview is added and deleted at the index
The present is a gift from heaven -- a film review of the journey of the soul
[leetcode] integer inversion [7]
Collapse of adjacent vertical outer margins
【论文笔记】Multi-Goal Reinforcement Learning: Challenging Robotics Environments and Request for Research
Learning notes of "hands on learning in depth"
服务熔断 Hystrix
Development error notes
Use of snippets in vscode (code template)
Pause and resume of cocos2dx Lua scenario
Embedded database development programming (zero)
记录QT内存泄漏的一种问题和解决方案
对象的序列化
嵌入式数据库开发编程(五)——DQL

![[speed pointer] 142 circular linked list II](/img/f8/222a360c01d8ef120b61bdd2025044.jpg)



![[merge array] 88 merge two ordered arrays](/img/e9/a73d9f22eead8e68c1e45c27ff6e6c.jpg)



