目录
CONTEST PRINT SERVER

** CONTEST PRINT SERVER:** <Excerpt in index | 首页摘要>

<The rest of contents | 余下全文>

Contest Print Server
Time Limit: 1000 MS Memory Limit: 32768 K
Total Submit: 111(26 users) Total Accepted: 35(25 users) Rating: Special Judge: No
Description
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.

Input
In the first line there is an integer T(T<=10),which indicates the number of test cases.

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.

Output
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”.

Sample Input
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
Sample Output
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
Source
HCPC2014校赛训练赛 2

题目大意是有一只很奇葩的打印机,只要纸张不够了,就得在没打印完的这个队伍重新开始

Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include<iostream>
#include<cmath>
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,s,x,y,mod;
struct node
{
char a[30];
int sum;
}b[100];
int main()
{
int T;
while(~scanf("%d",&T))
{
while(T--)
{
scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
int i;
char p[20];
getchar();
for(i=0;i<n;i++)
{
scanf("%s%s%d%s",b[i].a,p,&b[i].sum,p);
// printf("%s%s%d%s",b[i].a,p,b[i].sum,p);
}
int h=s;
for(i=0;i<n;i++)
{
while(b[i].sum>h)
{
printf("%d %s %s %s\n",h,"pages","for",b[i].a);
s=(s*x+y)%mod;
h=s;
}
h-=b[i].sum;
printf("%d %s %s %s\n",b[i].sum,"pages","for",b[i].a);
}
printf("\n");
}
}
return 0;
}
文章作者: 爱笑的k11
文章链接: http://1315402725.github.io/posts/2a66a2a9/
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 爱笑的k11
打赏
  • 微信
  • 支付寶

评论