点击打开链接

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

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

这题没法说了,说了全是泪啊,无脑模拟就可以过的,可是比赛的时候有人嘴贱问了一句会不会输出打印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的更多相关文章

  1. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  2. sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛

    Mountain Subsequences 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There ...

  3. 2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server

    题目描述     In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code ...

  4. 2013年山东省第四届ACM大学生程序设计竞赛 Alice and Bob

      Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very ...

  5. 2013年山东省第四届ACM大学生程序设计竞赛E题:Alice and Bob

    题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynom ...

  6. 山东省第四届ACM大学生程序设计竞赛解题报告(部分)

    2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...

  7. UPC 2224 / “浪潮杯”山东省第四届ACM大学生程序设计竞赛 1008 Boring Counting 主席树

    Problem H:Boring Counting Time Limit : 6000/3000ms (Java/Other)   Memory Limit : 65535/32768K (Java/ ...

  8. [2012山东省第三届ACM大学生程序设计竞赛]——n a^o7 !

    n a^o7 ! 题目:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2413 Time Lim ...

  9. angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...

随机推荐

  1. 合并master分支到自己的分支

    切换到自己的分支(比如:self):git checkout self: 在自己分支下,推送自己的分支到github远端仓库:git push --set-upstream origin self: ...

  2. jQuery tmpl用法总结

    之前很是头疼循环数据的渲染,搞一大堆的命名,一点点的赋值,很是麻烦,今天学习了一下jQuery插件tmpl,下面抛出一些使用方法,供以后参考: 官方网址:http://web.archive.org/ ...

  3. ibats注意

    <isNotEqual property="id" compareValue="0" prepend="and">id=#id# ...

  4. trunc函数

    date 为必要参数,是输入的一个日期值 fmt 参数可忽略,是日期格式,用以指定的元素格式来截去输入的日期值.忽略它则由最近的日期截去 下面是该函数的使用情况: trunc(sysdate,'yyy ...

  5. 遇到 Error creating the Web Proxy specified in the 'system.net/defaultProxy' configuration section的解决办法

    用记事本编辑*.EXE.config,在“<system.net>”节点加入<defaultProxy> <proxy usesystemdefault="Fa ...

  6. android学习笔记40——国际化和资源自适应

    国际化——Internationalization,简称I18N. 本地化——Localization,检查L10N. java国际化资源的思路: java提供国际化资源的思路,是将程序中的标签.提示 ...

  7. flash读取XML节点内容以及节点属性

    原文地址:http://hi.baidu.com/yqzdm/item/f95fd9d24679d916d90e44c9 一.xml的写法: 这里的xml只是在有限范围内的了解,限于写一些简单的用于f ...

  8. 从SVN导出指定版本号之间修改的文件

    当一个网站项目进入运营维护阶段以后,不会再频繁地更新全部源文件到服务器,这个时间的修改大多是局部的,因此更新文件只需更新修改过的文件,其他 没有修改过的文件就没有必要上载到服务器.但一个稍微上规模的网 ...

  9. JavaScript 中 4 种常见的内存泄露陷阱

    了解 JavaScript 的内存泄露和解决方式! 在这篇文章中我们将要探索客户端 JavaScript 代码中常见的一些内存泄漏的情况,并且学习如何使用 Chrome 的开发工具来发现他们.读一读吧 ...

  10. [hibernate]基本值类型映射之日期类型

    hibernate基本值类型映射中日期类型支持date,time,timestamp这三个选项,其中 date:对应数据库中的date类型,表示只显示日期 time:对应数据库中的time类型,表示只 ...