codeforces 234E Champions' League
传送门:http://codeforces.com/problemset/problem/234/E
题目大意:(注意要用文件)有n个队伍,每个队伍都有一个积分,按照积分高低顺序列出4个等级(每个等级n/4个,所以n一定是4的倍数),然后x,a,b,c这4个数就是一个随机数产生器,按照x=(x*a+b)mod c的规则来生成随机数,每生成一个随机数,便把这一个等级里的这个随机数所指向的队伍归类到group a里(或者是group b),当4个等级刷完一遍后,然后再刷另一个队伍。(p.s.我知道我解释得很丑,将就着看吧。)
ac程序
//
// main.cpp
// champions
//
// Created by zhangdenny on 16/7/14.
// Copyright (c) 2016年 Kirito. All rights reserved.
//
#include <functional>
#include <algorithm>
#include <exception>
#include <stdexcept>
#include <streambuf>
#include <iterator>
#include <string.h>
#include <stdlib.h>
#include <typeinfo>
#include <valarray>
#include <iostream>
#include <sstream>
#include <istream>
#include <stdio.h>
#include <climits>
#include <clocale>
#include <complex>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <ctype.h>
#include <cassert>
#include <cstdlib>
#include <utility>
#include <cstring>
#include <numeric>
#include <ostream>
#include <cwctype>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <bitset>
#include <cctype>
#include <string>
#include <vector>
#include <limits>
#include <locale>
#include <memory>
#include <cerrno>
#include <iosfwd>
#include <cfloat>
#include <cstdio>
#include <cwchar>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <ios>
#include <map>
#include <set>
#include <new>
#define ft first
#define sd second
#define np next_permutation
#define ll long long
#define pb push_back
using namespace std;
int n,x,a,b,c;
bool flag[105];
vector<int> ans[105];
pair<int,string> m[105];
int sui()
{
x*=a;
x+=b;
if(x<=c)
x=x;
else
x=x%c;
return x;
}
int main()
{
//freopen("input.txt","r",stdin);
//freopen("output.txt","w",stdout);
cin>>n;
cin>>x>>a>>b>>c;
for (int i=1;i<=n;i++)
{
cin>>m[i].sd;
cin>>m[i].ft;
}
sort(m+1,m+n+1);
n/=4;
for (int i=1;i<=n;i++)
{
for (int j=4;j>=1;j--)
{
int test=sui()%(n-i+1)+1;
int test1=j*n+1;
while (test>0)
{
test1--;
if (!flag[test1])
test--;
}
flag[test1]=1;
ans[i].push_back(test1);
}
cout<<"Group "<<char('A'+i-1)<<":"<<endl;
for (int j=0;j<4;j++)
cout<<m[ans[i][j]].sd<<endl;
}
return 0;
}