当前位置:网站首页>Battle plague Cup -- my account book
Battle plague Cup -- my account book
2022-07-28 06:39:00 【Step by step b】
My account book
The current situation of epidemic prevention and control is grim , In order to reduce the gathering of students caused by eating , It is stipulated that a representative should be sent out to buy food every time in a dormitory , Small W In the bedroom 6 people ( Number 1-6) Decided to send one person to buy it at a time 6 The same set meal . But it's more troublesome to transfer money immediately after each purchase , So they agreed that every time they went to buy food, they would pay in advance , After the epidemic is over, the unified settlement will be made .
Now I'll give you the time during the closed management of your dormitory n The serial number of each meal buyer and the unit price of each meal , Ask everyone about the income and expenditure of meal money after the end of the epidemic ?
Input format :
First line a positive integer n, Express n Meal
below n That's ok , The first i Line two positive integers x,y It means the first one i The meal consists of x Go buy food , Unit price per meal y element .
Output format :
Six integers in a row represent the money everyone owes others or others owe him .
If he owes someone money , Output negative .
If someone owes him money , Output positive numbers .
Note that there should be no extra spaces at the end of the line !
sample input :
3
1 5
2 10
3 5
sample output :
10 40 10 -20 -20 -20
#include<stdio.h>
int main() {
int a[7] = {
0};// Array a It's used to find out how the dormitory members buy meals , Subscript indicates member
int b[7] = {
0};// Array b It means that each member of the dormitory owes money
int n, i, t,x;
int sum = 0;
scanf("%d",&n);
for (i = 1; i <= n; i++) {
scanf("%d %d",&t,&x);
a[t] += x;// Express t Members buy meals , And the unit price of each meal is x element
sum += x;// Calculate how much each person spent
}
for (i = 1; i <= 6; i++) {
b[i] = a[i]*6 - sum;
}
for (i = 1; i <= 6; i++) {
if (i != 6) printf("%d ",b[i]);
else printf("%d",b[i]);
}
}
边栏推荐
猜你喜欢

Five categories of IP addresses

Treasure plan TPC system development DAPP construction

气传导蓝牙耳机哪个好、气传导蓝牙耳机排行榜

什么气传导蓝牙耳机好、配置比较高的气传导耳机推荐

【动态规划--买卖股票的最佳时期系列2】

set_ multicycle_ path

七夕送女朋友什么礼物好?不会送礼的男生速看!

【C语言】动态内存管理

SSAO By Computer Shader(一)

What are the open earphones? Four types of air conduction earphones with excellent sound quality are recommended
随机推荐
2022-06-07 responsebodyadvice caused the spring frame problem in swagger
OJ 1253 ordering problem
2022年七夕送女朋友什么礼物好?实用且好看的礼物推荐
江中ACM新生10月26日习题题解
OJ 1129 fraction matrix
Filter
Combine multiple ICs calendars into a single ICs calendar
STM32的IAP跳转相关bug经历
What is hash? (development of Quantitative Trading Robot System)
自定义组件--数据监听器
[PTA----树的遍历]
Leetcode 刷题日记 剑指 Offer II 047. 二叉树剪枝
刷题记录----链表
New Selenium
Use and safe shutdown of qthread thread in QT
微信小程序自定义编译模式
Explain the installation of MSDN 2015 and precautions
Development of clip arbitrage / brick carrying arbitrage system
做气传导耳机最好的是哪家、最好的气传导耳机盘点
2022-06-07 ResponseBodyAdvice导致Swagger出现弹框问题