UPC2226: Contest Print Server
来源:互联网 发布:淘宝搞活动时间 编辑:程序博客网 时间:2024/06/05 02:29
2226: Contest Print Server
Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 515 Solved: 119
[Submit][Status][Web Board]
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".
Please note that you should print an empty line after each case.
Sample Input
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
Sample Output
1 pages for Team15 pages for Team21 pages for Team31 pages for Team13 pages for Team25 pages for Team21 pages for Team3
HINT
Source
2013年山东省第四届ACM大学生程序设计竞赛
#include<cstdio>using namespace std;int main(){ int t; scanf("%d",&t); while(t--) { int n,s,x,y,mod; scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod); int rest=s; while(n--) { char name[21]; int p; scanf("%s request %d pages",name,&p); while(1){ if(p > rest){ printf("%d pages for %s\n",rest,name); s = rest = (s * x + y) % mod; } else { printf("%d pages for %s\n",p,name); rest -= p; break; } } } printf("\n"); } return 0;}注意有坑的地方就是当rest为0时,也需要输出。
加强读题
- UPC2226: Contest Print Server
- Contest Print Server 水题
- Problem J:Contest Print Server
- 第四届 Contest Print Server
- sdut 2624 Contest Print Server
- 山东省赛J题:Contest Print Server
- 第四届省赛试题 模拟 Contest Print Server
- sdut 2624 Contest Print Server (第四届省赛)
- sdut 2624 Contest Print Server (模拟)
- UPC:2226 Contest Print Server(模拟)
- 第四届 山东省ACM Contest Print Server
- UPC——2226——Contest Print Server
- [2013山东ACM省赛] Contest Print Server (模拟)
- 第四届山东ACM省赛---Contest Print Server
- 2013山东省第四届ACM省赛 Contest Print Server
- hrbust/哈理工oj Contest Print Server【模拟】
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
- 【恢复状态】第三届山东省ACM竞赛Problem J——Contest Print Server
- Xcode_使用小技巧(内存,快捷键)
- [前端] requireJS—详解
- “互联网+”时代,移动应用安全解决之道
- Android 编译错误:/usr/bin/ld: cannot find -luuid,/usr/bin/ld: cannot find -llzo2
- Android的服务(Service)(三)Service客户端的绑定与跨进程
- UPC2226: Contest Print Server
- OSPF
- 安装Ubuntu时的硬盘分区方案
- opencv 一些函数在的头文件
- 怎样编写高质量的Java代码
- 终极 Shell
- JavaScript parseint()理解
- pyqt5中把QtDesigner生成的ui文件转换为Python文件
- 关于Android Studio配置github