Zoj3705applications (Tenth Provincial competition of Zhejiang Province)

Source: Internet
Author: User

-> Question, click here <-

The question is too long. After reading the question patiently, it is quite simple. That is, a school selects m people from N acmers for the competition. because the number of places is limited, it is necessary to score each acmer and take the first m to the competition. There are a total of four scoring rules:

1: There is an OJ in the school. There are two types of questions on OJ. The question numbers are 4 non-repeated numbers. For each acmer, on OJ, 2.5 points are added for each question in the first category, and 1.5 points are added for each question in the second category. If the question number is a prime number, 1 point is added for each question, if any of the preceding three conditions is not met, add 0.3 points for each channel.

2: In a school competition (Team Competition) held by the school, the members of the excellent team can add. The specific addition is:

If the acmer team receives an equal 1 prize in the school competition, the acmer scores 36; the members of the equal 2 prize score 27; the members of the equal 3 prize score 18; the other members do not score.

3: If an acmer has played a certain game, there will be a rating after each completion, taking the rating of the 3rd largest rating in the previous games, and bringing the formula p = max (0, (rating-1200) /100) * 1.5, P is added to the total score;

4: If the acmer is a girl, add 33 points !!

In summary, calculate the total score of each acmer, and take the first m as the value.

Question Analysis: Pure simulation. What else can I analyze! For details, see the code:

#include <iostream>#include<cstdio>#include<cmath>#include<algorithm>#include<queue>#include<cstring>using namespace std;const int N = 501;const double eps = 1e-4;int maomao[N],old[N];bool is[10000];int n,m,r,s,teamnum;struct node1{    char t_name[31];    int prize;}team[N];struct node2{    char name[31],team[31],sex[31];    double score;    int p,c;    int solved[1001],rank[1001];}app[N];void getprm(){int i,j;memset(is,0,sizeof(is));for(i = 4;i <= 10000;i += 2)        is[i] = 1;    for(i = 3;i <= 10000;i += 2)    {        if(is[i] == 0)        {            for(j = i + i;j <= 10000;j += i)                is[j] = 1;        }    }}int ismaomao(int x){    int i;    for(i = 0;i < r;i ++)        if(maomao[i] == x)            return 1;    return 0;}int isold(int x){    int i;    for(i = 0;i < s;i ++)        if(old[i] == x)            return 1;    return 0;}int isprime(int x){    int i;    for(i = 2;i * i <= x;i ++)        if(x % i == 0)            return 0;    return 1;}int cmp(struct node2 a,struct node2 b){    if(fabs(a.score - b.score) < eps)        return strcmp(a.name,b.name) < 0;    else        return a.score > b.score;}int teamprize(int id){    int i;    for(i = 0;i < teamnum;i ++)    {        if(strcmp(app[id].team,team[i].t_name) == 0)            return team[i].prize;    }    return 0;}int main(){    getprm();    int t;    int i,j;    //while(scanf("%d",&t) != EOF)    //{     //   printf("%d\n",isprime(t));    //}    scanf("%d",&t);    while(t --)    {        scanf("%d%d",&n,&m);        scanf("%d",&r);        for(i = 0;i < r;i ++)            scanf("%d",&maomao[i]);        sort(maomao,maomao + r);        scanf("%d",&s);        for(i = 0;i < s;i ++)            scanf("%d",&old[i]);        sort(old,old + s);        scanf("%d",&teamnum);        for(i = 0;i < teamnum;i ++)        {            scanf("%s%d",team[i].t_name,&team[i].prize);        }        for(i = 0;i < n;i ++)        {            scanf("%s%s%s%d%d",app[i].name,app[i].team,app[i].sex,&app[i].p,&app[i].c);            if(app[i].sex[0] == 'F')                app[i].score = 33;            else                app[i].score = 0;            for(j = 0;j < app[i].p;j ++)            {                scanf("%d",&app[i].solved[j]);                //if(is[app[i].solved[j]] == 0)              //      app[i].score = app[i].score + 1;                if(ismaomao(app[i].solved[j]))                    app[i].score = app[i].score + 2.5;                else                {                    if(isold(app[i].solved[j]))                        app[i].score = app[i].score + 1.5;                    else                    {                        if(isprime(app[i].solved[j]))                            app[i].score = app[i].score + 1;                        else                            app[i].score = app[i].score + 0.3;                    }                }            }            for(j = 0;j < app[i].c;j ++)                scanf("%d",&app[i].rank[j]);            switch(teamprize(i))            {                case 1:app[i].score = app[i].score + 36;                break;                case 2:app[i].score = app[i].score + 27;                break;                case 3:app[i].score = app[i].score + 18;                break;                default:break;            }            sort(app[i].rank,app[i].rank + app[i].c);            if(app[i].c >= 3)            {                int tmp = app[i].rank[app[i].c - 3];                double tp = (tmp - 1200) / 100.0;                tp = tp * 1.5;                if(tp > 0)                    app[i].score = app[i].score + tp;            }        }        sort(app,app + n,cmp);        for(i = 0;i < m;i ++)            printf("%s %.3lf\n",app[i].name,app[i].score);    }    return 0;}

This question is not difficult, but it is very late. Maybe there are too many simple questions in this competition, so they are all busy with water questions. The game was a little in a hurry. I shook my hands and wrote a wrong variable. Wa had only passed the game six times. It was a lesson.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.