CodeForces Round #145(234E) - Champions' League

     规则看懂..裸做...


Program:

#include<iostream>
#include<stdio.h>
#include<string.h>
#include<cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<set>
#define ll long long
using namespace std; 
struct node
{
    char name[25];
    int rating;
}team[70];
int n,m,x,y,a,b,c;
bool used[70];
bool cmp(node a,node b)
{
    return a.rating>b.rating;
}
int main()
{  
    freopen("input.txt","r",stdin);    freopen("output.txt","w",stdout); 
    int i,g,k,j,h,num;
    scanf("%d%d%d%d%d",&n,&x,&a,&b,&c);
    for (i=0;i<n;i++) scanf("%s%d",team[i].name,&team[i].rating);
    sort(team,team+n,cmp);
    m=n/4;
    memset(used,false,sizeof(used));
    for (g=0;g<m;g++)
    {
           printf("Group %c:\n",'A'+g);
           for (k=0;k<4;k++)
           { 
                   y=(x*a+b)%c;
                   x=y;                  
                   h=x%(m-g); 
                   num=-1;
                   for (j=k*m;;j++)
                     if (!used[j])
                     {
                            num++;
                            if (num==h) break;
                     }
                   used[j]=true;
                   puts(team[j].name);                  
           }
    }
    return 0;
}


你可能感兴趣的:(c,struct,ini)