admin 管理员组

文章数量: 887007

第四届省赛试题 模拟 Contest Print Server

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

示例输入

23 7 5 6 177Team1 request 1 pagesTeam2 request 5 pagesTeam3 request 1 pages3 4 5 6 177Team1 request 1 pagesTeam2 request 5 pagesTeam3 request 1 pages

示例输出

1 pages for Team15 pages for Team21 pages for Team31 pages for Team13 pages for Team25 pages for Team21 pages for Team3

提示

来源

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

示例程序


这个题目的意思是说有一个打印机,如果纸张不够现在组要打的的纸张就要重新打,这个地方是个坑,但对于我 第一做来说真是不觉得是个坑啊,我注意到了,但是下面的s,不能拿来比较而是要用cnt,这样才能过,坑啊,我做 这个题目用了整整1个半小时,唉,自己实在太水了,竟然自己做然后不断改要做这么久,坑!!!!!


#include<iostream>
#include<cstdio>
#include<cstring>
#include<math.h>
using namespace std;
int n,s,x,y,mod;
char ss[300];
int i,j,t;
int T;
int h3,h4;
struct node
{int x,f;char name[30];
} unit[300];
int judge()
{for(i=1;i<=n;i++){if(!unit[i].f)return 1;}return 0;
}
int main()
{scanf("%d",&T);while(T--){scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);for(int e=1; e<=n; e++){//getchar();// gets(ss);// int a1,a2,a3,a4;//  char c1[100],c2[100];/* for(i=0; i<250; i++){if(ss[i]=='m')a1=i;if(ss[i]=='r')a2=i;if(ss[i]=='t')a3=i;if(ss[i]=='p')a4=i;if(ss[i]=='g')break;}int la=a2-a1-2;//1int lb=a4-a3-3;//1for(i=0; i<la; i++){c1[i]=ss[a1+i+1]-'0';}c1[i]='\0';for(i=0; i<lb; i++){c2[i]=ss[a3+2+i]-'0';}c2[i]='\0';int h1=0;int h2=0;for(i=0; i<la; i++){h1=h1+c1[i]*pow(10,la-i-1);}//printf("hhhh%d\n",h1);for(i=0; i<lb; i++){h2=h2+c2[i]*pow(10,lb-i-1);}unit[e].x=h2;unit[e].y=h1;unit[e].f=0;*/scanf("%s request %d pages",unit[e].name,&unit[e].x);// printf("%s  %d\n",unit[e].name,unit[e].x);unit[e].f=0;}// int flag=1;i=1;/*  for(i=1;i<=n;i++){printf("%s   %d  %d\n",unit[i].name,unit[i].x,unit[i].f);}*/int cnt=s;while(judge()){//h4=unit[i].x;//team//h3=unit[i].x;//page//printf("fjkdsjf");if(cnt>=unit[i].x){cnt=cnt-unit[i].x;//flag=1;unit[i].f=1;//printf("fjdskl");printf("%d pages for %s\n",unit[i].x,unit[i].name);i++;//进入到下一组}else{//flag=0;printf("%d pages for %s\n",cnt,unit[i].name);s=(s*x+y)%mod;/*if(s==0){s=(s*x+y)%mod;}*/cnt=s;}}printf("\n");}return 0;
}/**************************************Problem id	: SDUT OJ 2624 User name	: persue Result		: Accepted Take Memory	: 472K Take Time	: 0MS Submit Time	: 2014-02-25 20:26:40  
**************************************/





本文标签: 第四届省赛试题 模拟Contest Print Server