Problem J:Contest Print Server
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65535/32768K (Java/Other)
Problem 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
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
题意:
给出 T (<= 10),代表有 T 组 case。后给出 n(1 ~ 100),s(1 ~ 10007),x(1 ~ 10007),y(1 ~ 10007),mod (1 ~ 10007)代表有 n 个要求,每个要求都有一个 team 要求打印纸张数量,如果要求的这个张数 p <= s,则直接打印 s,若不满足,则先打印出剩下的 s 后,以 s = (ns * x + y)% mod 来更新纸张数量,ns 为最开始时候的原始纸张数量,更新完后再按要求打印出 p。
思路:
模拟。坑在输入,而且s == 0张的时候也会输出的。
AC:
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int main () { int t; scanf("%d", &t); while (t--) { int n, s, x, y, mod, ns; scanf("%d%d%d%d%d\n", &n, &s, &x, &y, &mod); ns = s; while (n--) { char name[25]; int p; scanf("%s request %d pages", name, &p); while (p > s) { printf("%d pages for %s\n", s, name); s = (ns * x + y) % mod; ns = s; } printf("%d pages for %s\n", p, name); s -= p; } printf("\n"); } return 0; }
相关推荐
Ulm Local Contest1996-1999
maa-the-Contest-Problem-book
Turn theory into practice by entering COMAP's Mathematical Contest in Modeling (MCM). The study of mathematics as a subject in its own right may have started with Pythagoras, but people have been ...
DPA Contest V2相关情况简介~
UCF Local Contest — September 5, 2015 UCF Local Contest — September 5, 2015 UCF Local Contest — September 5, 2015
Andrew Stankevich Contest 45 Problem analysis, cf
ACM International Collegiate Programming Contest 2000/2001 Mid-Central European Regional Contest
国际大学生程序设计竞赛
2008 Benelux Algorithm Programming Contest.rar 包含题目、测试数据、解答
有n头牛比赛,m种比赛结果,最后问你一共有多少头牛的排名被确定了,其中如果a战胜b,b战胜c,则也可以说a战胜c,即可以传递胜负。这样如果一头牛的被x头牛打败,打败y头牛,且x+y=n-1,则我们容易知道这头牛的排名...
2013 ACM ICPC Southeast USA Regional Programming Contest 原题
三字节国际象棋服务器服务器。... 在端口1234上运行服务器python server.py 1234 random_client.py是示例客户端实现。 连接到本地服务器python random_client.py localhost 1234 TournamentName PlayerName
这是08年D类样题仅供大家备考使用2008 National English Contest for College Students (Level D) (Sample)
2008 ACM ICPC South Central USA Regional Programming Contest
自述 欢迎来到游戏大赛服务器! 您需要知道的第一件事:您应该阅读的所有内容都在 README 文件夹中。 在那里,我们有关于整个站点、测试、功能、实践和未来工作的不同文档。 还有一个来自之前的 J-Term 2014 组的 ...
tencent innovation contest title of test
2019 Multi-University Training Contest 4(2019hdu多校第六场数据与标程)
2014 Multi-University Training Contest 3(标程)
Contest Result.html
contest3.jsp