USACO gift1
来源:互联网 发布:百度网盘搜索 知乎 编辑:程序博客网 时间:2024/06/06 13:58
#include <iostream>
#include <cstdio>
#include <string>
using namespace std;
#include <cstdio>
#include <string>
using namespace std;
struct gitf {
string name;
int money0; //定义一个简单的结构体,表示名字,初始的金钱,最后的金钱
int money;
}a[10];
string name;
int money0; //定义一个简单的结构体,表示名字,初始的金钱,最后的金钱
int money;
}a[10];
int main()
{
freopen("gift1.in", "r", stdin);
freopen("gift1.out", "w", stdout);
{
freopen("gift1.in", "r", stdin);
freopen("gift1.out", "w", stdout);
int n;
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].name; //读入名字
cin >> n;
for (int i = 0; i < n; i++) cin >> a[i].name; //读入名字
for (int i = 0; i < n; i++) {
string s; int amount; int people;
cin >> s; cin >> amount; cin >> people; //读入每个人的初始金钱和要分钱的人数
cin >> s; cin >> amount; cin >> people; //读入每个人的初始金钱和要分钱的人数
int spent;
if (people == 0) spent=0;
else spent = amount / people;
//cout << spent << endl;
if (people == 0) spent=0;
else spent = amount / people;
//cout << spent << endl;
for (int j = 0; j < n; j++)
if (a[j].name == s) {
a[j].money0 = amount;
a[j].money += amount; //注意这里的money不要 ” = ” amount
a[j].money -= people*spent;
}
if (a[j].name == s) {
a[j].money0 = amount;
a[j].money += amount; //注意这里的money不要 ” = ” amount
a[j].money -= people*spent;
}
for (int j = 0; j < people; j++) {
string recer;
cin >> recer;
//cout << recer << endl;
for (int x = 0; x < n; x++) if (a[x].name == recer) a[x].money += spent; //分钱
}
string recer;
cin >> recer;
//cout << recer << endl;
for (int x = 0; x < n; x++) if (a[x].name == recer) a[x].money += spent; //分钱
}
}
for (int i = 0; i < n; i++) {
cout << a[i].name << " " << (a[i].money - a[i].money0) << endl; //打印
}
cout << a[i].name << " " << (a[i].money - a[i].money0) << endl; //打印
}
return 0;
}
}
0 0
- USACO gift1
- USACO gift1
- usaco gift1
- USACO gift1
- usaco——gift1
- USACO 1.1 gift1
- usaco 1.1.2 gift1
- USACO 1.1-gift1
- USACO第二题gift1,礼物
- USACO 1.1.2 Greedy Gift Givers (gift1)
- USACO 1.1 Greedy Gift Givers (gift1)
- gift1
- gift1
- USACAO gift1
- Gift1解题报告
- USACO1.1:gift1
- gift1-section1.1
- USACO
- 数据结构实验之排序三:bucket sort
- 子类重写父类方法注意
- 多线程实现四个窗口共同售10张票(java)
- 在linux上使用c++实现http/2协议进行通信
- 31. Next Permutation
- USACO gift1
- 微积分常用公式、微分方程、级数
- lightoj 1025 区间dp
- 基于jQuery+JSON的省市联动效果,详细的描述
- cycript
- POJ 3321 Apple Tree
- Hibernate的inverse,cascade属性简单介绍
- Red5的安装与测试
- 题解:艾米利亚的魔法