第四届 Contest Print Server
2015-05-05 19:24
344 查看
DescriptionIn 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.InputIn 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.OutputEvery 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 caseSample Input
23 7 5 6 177
Team1 request 1 pages
Team2 request 5 pages
Team3 request 1 pages
3 4 5 6 177Team1 request 1 pages
Team2 request 5 pages
Team3 request 1 pagesSample 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
#include <iostream>#include <string.h>#include <algorithm>using namespace std;int main(){ int T; cin>>T; while(T--) { int n,s,x,y,mod; int p,count=0; string team,str1,str2; cin>>n>>s>>x>>y>>mod; while(n--) { cin>>team>>str1>>p>>str2; if(s>=p+count) { cout<<p<<" pages for "<<team<<endl; count=count+p; } else { while(s<p+count) { cout<<s-count<<" pages for "<<team<<endl; s=(s*x+y)%mod; count=0; } if(s>=p+count) { cout<<p<<" pages for "<<team<<endl; count+=p; } } } cout<<endl; } return 0;}
相关文章推荐
- 山东省第四届ACM大学生程序设计竞赛-Contest Print Server(模拟)
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
- sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
- sdut 2624 Contest Print Server (第四届省赛)
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
- 第四届山东ACM省赛---Contest Print Server
- [2013山东省第四届ACM大学生程序设计竞赛]——Contest Print Server
- sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
- Contest Print Server (2013年山东省第四届ACM大学生程序设计竞赛):
- sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
- 2013年山东省第四届ACM大学生程序设计竞赛——Contest Print Server
- 山东省第四届ACM省赛题——Contest Print Server(模拟)
- 2013山东省第四届ACM省赛 Contest Print Server
- 第四届 山东省ACM Contest Print Server
- Contest Print Server(山东省第四届ACM大学生程序设计竞赛 )
- 山东省赛J题:Contest Print Server
- [2013山东ACM省赛] Contest Print Server (模拟)
- 【恢复状态】第三届山东省ACM竞赛Problem J——Contest Print Server