标签:
/* 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; }
简单模拟题,写着玩
标签:
原文地址:http://www.cnblogs.com/helloworld-c/p/4915544.html