标签:
/* ID: modengd1 PROG: gift1 LANG: C++ */ #include <iostream> #include<string.h> #include<stdio.h> using namespace std; char names[30][20]; int acount[30]; int counter,N; int getIndex(char name[20]) { for(int i=0;i<counter;i++) { if(strcmp(names[i],name)==0) return i; } strcpy(names[counter],name); return counter++; } int main() { freopen("gift1.in","r",stdin); freopen("gift1.out","w",stdout); int a,b,money; scanf("%d",&N); memset(acount,0,sizeof(acount)); counter=0; char name[20]; for(int i=0;i<N;i++) { scanf("%s",name); getIndex(name); } for(int j=0;j<counter;j++) { scanf("%s",name); int giver=getIndex(name); scanf("%d%d",&a,&b); money=0; if(b!=0) { acount[giver]-=((a)-(a%b)); money=a/b; } for(int i=0;i<b;i++) { scanf("%s",name); int receive=getIndex(name); acount[receive]+=money; } } for(int i=0;i<counter;i++) { for(int j=0;names[i][j]!=‘\0‘;j++) printf("%c",names[i][j]); putchar(‘ ‘); printf("%d\n",acount[i]); } return 0; }
标签:
原文地址:http://www.cnblogs.com/modengdubai/p/4758964.html