Create 1057_1408080213.c

pull/45/head
Kirigaya Kazuto 2016-10-12 11:24:03 +08:00 committed by GitHub
parent bf3396c4ad
commit 82a316ba16
1 changed files with 55 additions and 0 deletions

55
QUSTOJ/1057_1408080213.c Normal file
View File

@ -0,0 +1,55 @@
#include<stdio.h>
#include<string.h>
int main()
{
char a[12][20], temp[20], name[20];// name,the number = the name
int qian[20],shou[20],song[20];
int m, r;// money the number of people
int n, i, j, k, l;
while(scanf("%d", &n)!=EOF)
{
for(i=0; i<n ; ++i)
{
scanf("%s", a[i]);
qian[i]=0;
}
for(i=0; i<n; ++i)
{
scanf("%s", &name);
for(l=0; l<n; ++l)
{
if(strcmp(name,a[l])!=0)
continue;
else
scanf("%d%d", &m, &r);
if(r==0)
{
qian[l]=qian[l]+m;
song[l]=0;
}
else
{
qian[l]= qian[l]+ m%r - m;
song[l]= m/r;
}
for(j=0; j<r; ++j)
{
scanf("%s", &temp);
for(k=0; k<n; ++k)
{
if(strcmp(temp,a[k])==0)
{
qian[k]+=song[l];
break;
}
}
}
}
}
for(i=0; i<n; ++i)
printf("%s %d\n", a[i], qian[i]);
}
return 0;
}