#include <iostream> #include <map> using namespace std; map<string,int> na_mo; int main() { int n; cin>>n; string name[n],ren[n][n],name1[n]; int renshu[n]; int d=0; for(int i=0;i<n;i++){ cin>>name[i]; } for(int i=0;i<n;i++){ cin>>name1[i]; cin>>na_mo[name1[i]]; cin>>renshu[i]; for(int b=0;b<renshu[i];b++){ cin>>ren[b][d]; na_mo[ren[b][d]]+=na_mo[name1[i]]/renshu[i]; cout<<na_mo[ren[b][d]]; } d++; if(renshu[i]!=0){ na_mo[name1[i]]=na_mo[name1[i]]-na_mo[name1[i]]+na_mo[name1[i]]%renshu[i]; } } for(int i=0;i<n;i++){ cout<<name[i]<<":"; cout<<na_mo[name1[i]]<<endl; } return 0; }
标签:int,na,mo,renshu,cin,互赠,name1,礼物 From: https://www.cnblogs.com/As10016/p/17500124.html