码迷,mamicode.com
首页 > 其他好文 > 详细

usaco1-02

时间:2015-10-27 22:09:05      阅读:169      评论:0      收藏:0      [点我收藏+]

标签:

/*
ID:i_goodboy1
PROG:gift1
LANG:C++
*/
#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#define F(i,a,b) for(int i=a;i<=b;i++)
#define outs(s) std:cout<<s<<endl
using namespace std;
int n;
map<string,int> q;
struct e
{
    string name;
    int recive,money;
}man[20];
void read()
{
    string c;
    scanf("%d",&n);
    int i;
    i=1;
    F(i,1,n)
    {
        cin>>c;
        man[i].name=c;
        q[c]=i;
        man[i].recive=0;
    }
    int m,num,g,mo;
    i=1;
    int j;
    F(i,1,n)
    {
        cin>>c;
        m=q[c];
        scanf("%d%d",&mo,&num);
        man[m].money=mo;
        if(num!=0)
            mo=mo/num;
        man[m].recive+=man[m].money-mo*num;
        j=1;
        F(j,1,num)
        {
            cin>>c;
            g=q[c];
            man[g].recive+=mo;
        }
    }
}
void solve()
{
    int i=1;
    F(i,1,n)
    {
        cout<<man[i].name<< ;
        outs(man[i].recive-man[i].money);
    }
}
int main()
{
    freopen("gift1.in","r",stdin);
    freopen("gift1.out","w",stdout);
    read();
    solve();
    return 0;
}

 

简单模拟题,写着玩

usaco1-02

标签:

原文地址:http://www.cnblogs.com/helloworld-c/p/4915544.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!