首页 > 其他 > 详细

usaco1-02

时间:2015-10-27 22:06:00      阅读:132      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!