zoj 3705 Applications

模拟题

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;

const double eps=1e-8;
struct student{
	char name[50];
	double score;
}ss[1005];

int maomao[1000],old[1000];
struct node{
	char teamname[50];
	int pos;
}ttt[1000];

int is_prime(int n){
    int i;
    for(i=2;i<=sqrt(n);i++){
        if(n%i==0) return 0;
    }
    return 1;
}

int cmp1(int a,int b){
    return a>b;
}

int cmp2(struct student a,struct student b){
    if(fabs(a.score-b.score)<eps) return strcmp(a.name,b.name)<0;
    else return a.score>b.score;
}
int main()
{
	int t;
	scanf("%d",&t);
	while(t--){
		int n,m,i,j,k;
		memset(maomao,-1,sizeof(maomao));
		memset(old,-1,sizeof(old));
		scanf("%d%d",&n,&m);
		int r;
		scanf("%d",&r);
		for(i=0;i<r;i++) scanf("%d",&maomao[i]);
		int s;
		scanf("%d",&s);
		for(i=0;i<s;i++) scanf("%d",&old[i]);
		int q;
		scanf("%d",&q);
		getchar();
		for(i=0;i<q;i++){
			scanf("%s %d",ttt[i].teamname,&ttt[i].pos);
		}
		for(i=0;i<n;i++){
			char team[50],sex;
			int pp,c;
			scanf("%s %s %c %d %d",ss[i].name,team,&sex,&pp,&c);
			ss[i].score=0;
			for(j=0;j<q;j++){
				if(strcmp(team,ttt[j].teamname)==0){
					if(ttt[j].pos==1) ss[i].score+=36;
					else if(ttt[j].pos==2) ss[i].score+=27;
					else if(ttt[j].pos==3) ss[i].score+=18;
					break;
				}
			}
            if(sex==‘F‘) ss[i].score+=33;
            for(j=0;j<pp;j++){
                int proid;
                int flag1=0,flag2=0;
                scanf("%d",&proid);
                for(k=0;k<r;k++){
                    if(proid==maomao[k]){
                        ss[i].score+=2.5;
                        flag1=1;
                        break;
                    }
                }
                if(flag1==0){
                    for(k=0;k<s;k++){
                        if(proid==old[k]){
                            ss[i].score+=1.5;
                            flag2=1;
                            break;
                        }
                    }
                    if(flag2==0){
                        if(is_prime(proid)) ss[i].score+=1;
                        else ss[i].score+=0.3;
                    }
                }
            }
            double sy[1005];
            for(j=0;j<c;j++){
                scanf("%lf",&sy[j]);
            }
            getchar();
            sort(sy,sy+c,cmp1);
            double rr=0;
            if(c>=3){
                rr=(sy[2]-1200)*1.5/100;
            }
            ss[i].score+=rr;
		}
		sort(ss,ss+n,cmp2);
		for(i=0;i<m;i++) printf("%s %.3lf\n",ss[i].name,ss[i].score);
	}
	return 0;
}


zoj 3705 Applications,布布扣,bubuko.com

zoj 3705 Applications

上一篇:微信版本更新日志分析


下一篇:【技巧】如何使用客户端发布BLOG+如何快速发布微信公众号文章