ZOJ 3705 Applications 類比

來源:互聯網
上載者:User

標籤:style   blog   class   code   java   tar   

#pragma comment(linker, "/STACK:1024000000,1024000000")#include<cstdio>#include<cstring>#include<cstdlib>#include<algorithm>#include<iostream>#include<sstream>#include<cmath>#include<climits>#include<string>#include<map>#include<queue>#include<vector>#include<stack>#include<set>using namespace std;typedef long long ll;typedef unsigned long long ull;typedef pair<int,int> pii;#define pb(a) push(a)#define INF 0x1f1f1f1f#define lson idx<<1,l,mid#define rson idx<<1|1,mid+1,r#define PI  3.1415926535898template<class T> T min(const T& a,const T& b,const T& c) {    return min(min(a,b),min(a,c));}template<class T> T max(const T& a,const T& b,const T& c) {    return max(max(a,b),max(a,c));}void debug() {#ifdef ONLINE_JUDGE#else    freopen("in.txt","r",stdin);    freopen("d:\\out1.txt","w",stdout);#endif}int getch() {    int ch;    while((ch=getchar())!=EOF) {        if(ch!=‘ ‘&&ch!=‘\n‘)return ch;    }    return EOF;}const int maxn=505;const double eps=1e-8;int isprime(int n){    if(n==1||n==0)return 0;    if(n==2)return 1;    for(int i=2;i*i<=n;i++)        if(n%i==0)return false;    return true;}struct APP{    char name[50];    char belong[50];    char sex;    vector<int> solved;    vector<int> rating;    double score;    bool operator < (const APP &ant ) const    {        if(fabs(score-ant.score)>eps) return score>ant.score;        else return strcmp(name,ant.name)<0?1:0;    }}da[maxn];map<string,int> prize;int prob[10005];int n,m;void cal(){    for(int i=1;i<=n;i++)    {        da[i].score=0;        for(int j=0;j<da[i].solved.size();j++)        {            int id=da[i].solved[j];            if(prob[id]==1) da[i].score+=2.5;            else if(prob[id]==2) da[i].score+=1.5;            else if(isprime(id)) da[i].score+=1;            else da[i].score+=0.3;        }        int x=prize[string(da[i].belong)];        if(x!=0&&x<=3) da[i].score+= (5-x)*9;        int rat;        if(da[i].rating.size()>=3)            rat=max(1200,da[i].rating[2]);        else rat=1200;        da[i].score+= (rat-1200)/100.0*1.5;        if(da[i].sex==‘F‘) da[i].score += 33;    }    sort(da+1,da+n+1);}int main(){    int t;    scanf("%d",&t);    for(int ca=1;ca<=t;ca++)    {        scanf("%d%d",&n,&m);        memset(prob,0,sizeof(prob));        for(int i=1;i<=2;i++)        {            int x; scanf("%d",&x);            for(int j=1;j<=x;j++)            {                int a; scanf("%d",&a);                prob[a]=i;            }        }        int teamnum;        scanf("%d",&teamnum);        prize.clear();        for(int i=1;i<=teamnum;i++)        {            char s[50];            int x;            scanf("%s%d",s,&x);            prize[string(s)]=x;        }        for(int i=1;i<=n;i++)        {            da[i].solved.clear();            da[i].rating.clear();            scanf("%s%s",da[i].name,da[i].belong);            da[i].sex=getch();            int a,b; scanf("%d%d",&a,&b);            for(int j=1;j<=a;j++)            {                int id; scanf("%d",&id);                da[i].solved.push_back(id);            }            for(int j=1;j<=b;j++)            {                int rat; scanf("%d",&rat);                da[i].rating.push_back(rat);            }            sort(da[i].rating.begin(),da[i].rating.end(),greater<int>());        }        cal();        for(int i=1;i<=m;i++)        {            printf("%s %.3lf\n",da[i].name,da[i].score);        }    }    return 0;}
View Code

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.