#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
struct node
{
public:
char name[11];
int time[7];
int count,sum,tot,geo;
double dui;
}team[20];
int cmp(const void *a,const void *b)
{
struct node *aa=(struct node *)a;
struct node *bb=(struct node *)b;
if(aa->count!=bb->count)
return bb->count-aa->count;
else if(aa->sum!=bb->sum)
return aa->sum-bb->sum;
else if(aa->geo!=bb->geo)
return aa->geo-bb->geo;
else return strcmp(aa->name,bb->name);
}
int main()
{
freopen("t.txt","r",stdin);
int T=1,n,i,k;
for(;;)
{
scanf("%d",&n);
if(n==0)break;
printf("CONTEST %d\n",T++);
for(i=0;i<n;i++)
{
team[i].count=team[i].dui=team[i].sum=0;
scanf("%s",&team[i].name);
for(k=0;k<7;k++)
{
scanf("%d",&team[i].time[k]);
if(team[i].time[k]!=0)
{
team[i].count++;
team[i].dui+=log((double)team[i].time[k]);
team[i].sum+=team[i].time[k];
}
}
if(team[i].count!=0)
{
team[i].dui=exp(team[i].dui/team[i].count);
team[i].geo=(int)(team[i].dui+0.5);
}
else team[i].geo=0;
}
qsort(team,n,sizeof(team[0]),cmp);
team[0].tot=1;
printf("01 %-10s %d %4d %3d %3d %3d %3d %3d %3d %3d %3d\n",team[0].name,team[0].count,team[0].sum,team[0].geo,
team[0].time[0],team[0].time[1],team[0].time[2],team[0].time[3],team[0].time[4],team[0].time[5],team[0].time[6]);
for(i=1;i<n;i++)
{
if(team[i].count==team[i-1].count&&team[i].sum==team[i-1].sum&&team[i].geo==team[i-1].geo)
team[i].tot=team[i-1].tot;
else team[i].tot=i+1;
if(i<9)
printf("0");
printf("%d %-10s %d %4d %3d %3d %3d %3d %3d %3d %3d %3d\n",team[i].tot,team[i].name,team[i].count,team[i].sum,team[i].geo,
team[i].time[0],team[i].time[1],team[i].time[2],team[i].time[3],team[i].time[4],team[i].time[5],team[i].time[6]);
}
}
return 0;
}
POJ1245 Programmer, Rank Thyself
最新推荐文章于 2017-11-15 22:56:12 发布