# 山东省第四届ACM大学生程序设计竞赛-Contest Print Server（模拟）

Boring Counting Time Limit: 3000ms   Memory limit: 65536K  有疑问？点这里^_^ 题目描述     In this problem you are given a number sequence P consisting

## 题目描述

In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code any time. Here you need to write a contest print server to handle all the requests.

## 输入

In each case,the first line contains 5 integers n,s,x,y,mod (1<=n<=100, 1<=s,x,y,mod<=10007), and n lines of requests follow. The request is like "Team_Name request p pages" (p is integer, 0<p<=10007, the length of "Team_Name" is no longer than 20), means the team "Team_Name" need p pages to print, but for some un-know reason the printer will break down when the printed pages counter reached s(s is generated by the function s=(s*x+y)%mod ) and then the counter will become 0. In the same time the last request will be reprint from the very begin if it isn't complete yet(The data guaranteed that every request will be completed in some time).
You can get more from the sample.

## 输出

Every time a request is completed or the printer is break down,you should output one line like "p pages for Team_Name",p is the number of pages you give the team "Team_Name".

Please note that you should print an empty line after each case.

## 示例输入

```2
3 7 5 6 177
Team1 request 1 pages
Team2 request 5 pages
Team3 request 1 pages
3 4 5 6 177
Team1 request 1 pages
Team2 request 5 pages
Team3 request 1 pages```

## 示例输出

```1 pages for Team1
5 pages for Team2
1 pages for Team3

1 pages for Team1
3 pages for Team2
5 pages for Team2
1 pages for Team3```

## 来源

2013年山东省第四届ACM大学生程序设计竞赛

The Best Seat in ACM Contest 题目：http://acm.sdut.edu.cn/sdutoj/problem.phpaction=showproblem&problemid=2409 Time Limit: 1000ms Memory limit: 65536K

```/*
* 文件名称：print.cpp
* 作    者：单昕昕
* 完成日期：2016年4月12日
* 版 本 号：v1.0
*/
#include <iostream>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <time.h>
#include <stdlib.h>
using namespace std;

int main()
{
int t;
scanf("%d",&t);
while(t--)
{
int n,s,x,y,mod,cnt=0,flag=0;
scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
while(n--)
{
char s1[20],s2[10],s3[10];
int p;
scanf("%s%s%d%s",s1,s2,&p,s3);
A:
cnt+=p;
if(cnt<=s)
printf("%d pages for %s\n",p,s1);
else
{
cnt-=p;
printf("%d pages for %s\n",s-cnt,s1);
s=(s*x+y)%mod;
cnt=0;//此时当前的p依然有可能超过s所以要goto重判
goto A;
}
}
cout<<endl;
}
return 0;
}
```

Execution of Paladin Time Limit: 2000ms   Memory limit: 65536K  有疑问？点这里^_^ 题目描述 Murloc is a powerful race in Hearthstone. In the set League

Contest Print Server Time Limit: 1000ms   Memory limit: 65536K  有疑问？点这里^_^ 题目描述     In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your sourc

×
• 登录
• 注册

×

### 请激活账号

为了能正常使用评论、编辑功能及以后陆续为用户提供的其他产品，请激活账号。

您的注册邮箱： 修改

如果您没有收到激活邮件，请注意检查垃圾箱。