POJ1245 Programmer, Rank Thyself

#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;
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值