2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
2226: Contest Print Server
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 53 Solved: 18
[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
Sample Output
HINT
Source
这题没法说了,说了全是泪啊,无脑模拟就可以过的,可是比赛的时候有人嘴贱问了一句会不会输出打印0张的情况,裁判回了一句no,从此全场走上了一条不归路,这题只有在最后恰好打印完才不会输出0张,在打印过程中出现刚好打印完的情况下,下一个队申请打印的时候是一定会输出一句打印0张的,天坑!!!看了AC代码才明白,哎
- #include<stdio.h>
- int main()
- {
- // freopen("in.txt", "r", stdin);
- 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 count = s;
- int i;
- for(i = 0; i < n; i++)
- {
- char name[40], request[10], page[10];
- int num;
- scanf("%s %s %d %s", name, request, &num, page);
- while(1)
- {
- if(num > count)
- {
- printf("%d pages for %s\n", count, name);
- s = (s * x + y) % mod;
- if(s == 0)
- s = (s * x + y) % mod;
- count = s;
- }
- else if(num == count)
- {
- printf("%d pages for %s\n", count, name);
- count -= num;
- break;
- }
- else
- {
- printf("%d pages for %s\n", num, name);
- count -= num;
- break;
- }
- }
- }
- printf("\n");
- }
- return 0;
- }
2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server的更多相关文章
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛
Mountain Subsequences 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There ...
- 2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server
题目描述 In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code ...
- 2013年山东省第四届ACM大学生程序设计竞赛 Alice and Bob
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very ...
- 2013年山东省第四届ACM大学生程序设计竞赛E题:Alice and Bob
题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynom ...
- 山东省第四届ACM大学生程序设计竞赛解题报告(部分)
2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...
- UPC 2224 / “浪潮杯”山东省第四届ACM大学生程序设计竞赛 1008 Boring Counting 主席树
Problem H:Boring Counting Time Limit : 6000/3000ms (Java/Other) Memory Limit : 65535/32768K (Java/ ...
- [2012山东省第三届ACM大学生程序设计竞赛]——n a^o7 !
n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...
- angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...
随机推荐
- .net framework4与其client profile版本的区别
简而言之,client profile版本是完整版本的一个子集.包含大多数最常用的功能并减小了体积,以便更容易的安装和发布,同时还有微软所声称的一些好处,比如因为减少了某些库,所以使其更加安全等等. ...
- Intellij Idea 12 生成serialVersionUID的方法
默认情况下Intellij IDEA是关闭了继承了java.io.Serializable的类生成serialVersionUID的警告.如果需要ide提示生成serialVersionUID,那么需 ...
- javascript 定义正则表达式
js中定义正则表达式有两种,使用RegExp和使用字面量. 使用字面量定义时需要注意:必须以/开始,以/结束,就像定义字符串一样("test"). 但是,js的正则表达式可以通过指 ...
- 测试img在不显示时是否加载?
一直搞不明白,隐藏的元素的背景图,在页面加载时,是否自动加载? img隐藏时,图片会加载吗? 测试代码如下: <!DOCTYPE html> <html> <head&g ...
- (转)关于List中FindAll用法的一些简单示例
本文转载自:http://blog.csdn.net/luoxufeng/article/details/6925982 using System; using System.Collections. ...
- 修改tcp内核参数:somaxconn
修改somaxconn 该内核参数默认值一般是128(定义了系统中每一个端口最大的监听队列的长度),对于负载很大的服务程序来说大大的不够.一般会将它修改为2048或者更大. echo 2048 > ...
- ResultSet的getInt(),getString()方法
数据库tt的examstudent数据表如下: 在MySQL中执行查询语句如下: ResultSet rs = null; String sql="SELECT flow_id,Typ ...
- ASP.NET网页验证码常用方法
验证码生产类 using System; using System.Data; using System.Configuration; using System.Web; using System.W ...
- python使用xlrd模块读写Excel文件的方法
本文实例讲述了python使用xlrd模块读写Excel文件的方法.分享给大家供大家参考.具体如下: 一.安装xlrd模块 到python官网下载http://pypi.python.org/pypi ...
- Bellman-Ford & SPFA 算法——求解单源点最短路径问题
Bellman-Ford算法与另一个非常著名的Dijkstra算法一样,用于求解单源点最短路径问题.Bellman-ford算法除了可求解边权均非负的问题外,还可以解决存在负权边的问题(意义是什么,好 ...