UPC2226: Contest Print Server

网友投稿 258 2022-09-04

UPC2226: Contest Print Server

2226: Contest Print Server

Time Limit: 1 Sec   Memory Limit: 128 MB

Submit: 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

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大学生程序设计竞赛​​

#includeusing 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时,也需要输出。

加强读题

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:SDKD TeamContest A-E - 1005
下一篇:UPC2225: The number of steps
相关文章

 发表评论

暂时没有评论,来抢沙发吧~