Contest Print Server组队第四场J

简介: 问题 J:Contest Print Server时间限制: 1 Sec 内存限制: 128 MB题目描述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.

问题 J:Contest Print Server

时间限制: 1 Sec 内存限制: 128 MB


题目描述


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.


输入


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.


输出


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.


样例输入 Copy


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


样例输出 Copy


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


题意是:有一台打印机,打印的时候如果累计打印到 s 张还没有将当前任务打印完,那么就会重新打印着一份文件,在此之前 s 会重新生成一个,生成的方式是s = (s * x + y) % mod;

代码没什么东西,但是有一个坑点,虽然开始输入的 s 是一个>=1的数,但是如果重新生成的s为0的话,就会再次重新生成一个 s


code:


int T = read;
    while(T--){
        n=read,s=read,x=read,y=read,mod=read;int sy=s;
        for(int i=1;i<=n;i++){
            char s1[50],s2[50],s3[50];
            int tot;
            scanf("%s%s%d%s",s1,s2,&tot,s3);
            if(tot<=sy){
                printf("%d pages for %s\n",tot,s1);
                sy -= tot;
            }else{
                while(1){
                    if(tot <= sy){
                        printf("%d pages for %s\n",tot,s1); sy-=tot;
                        break;
                    }else{
                        printf("%d pages for %s\n",sy,s1); s=fun();
                        if(s==0) s=(s*x+y)%mod;
                        sy=s;
                    }
                }
            }
        }
        puts("");
    }



目录
相关文章
|
11天前
|
机器学习/深度学习 算法 数据挖掘
【博士每天一篇文论文-算法】A small-world topology enhances the echo state property and signal propagationlun
本文研究了小世界拓扑结构在回声状态网络(ESN)中的作用,发现具有层级和模块化组织的神经网络展现出高聚类系数和小世界特性,这有助于提高学习性能和促进信号传播,为理解神经信息处理和构建高效循环神经网络提供了新的视角。
17 0
【博士每天一篇文论文-算法】A small-world topology enhances the echo state property and signal propagationlun
|
前端开发
前端项目实战贰拾-​sourceTree出现sourceTree The host key is not cached for this server
前端项目实战贰拾-​sourceTree出现sourceTree The host key is not cached for this server
69 0
前端项目实战贰拾-​sourceTree出现sourceTree The host key is not cached for this server
|
C语言 C++
PAT (Basic Level) Practice (中文)1099 性感素数(20分)
“性感素数”是指形如 (p, p+6) 这样的一对素数。之所以叫这个名字,是因为拉丁语管“六”叫“sex”(即英语的“性感”)。(原文摘自 http://mathworld.wolfram.com/SexyPrimes.html) 现给定一个整数,请你判断其是否为一个性感素数。
121 0
|
存储
PAT (Basic Level) Practice (中文) 1041 考试座位号 (15 分)
PAT (Basic Level) Practice (中文) 1041 考试座位号 (15 分)
78 0
PAT (Basic Level) Practice (中文) 1041 考试座位号 (15 分)
|
存储 测试技术
PAT (Basic Level) Practice (中文) 1004 成绩排名 (20 分)
PAT (Basic Level) Practice (中文) 1004 成绩排名 (20 分)
76 0
PAT (Basic Level) Practice (中文) 1036 跟奥巴马一起编程 (15 分) p89
PAT (Basic Level) Practice (中文) 1036 跟奥巴马一起编程 (15 分) p89
146 0
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
PAT (Advanced Level) Practice - 1068 Find More Coins(30 分)
100 0
PAT (Basic Level) Practice (中文)- 1052 卖个萌(20 分)
PAT (Basic Level) Practice (中文)- 1052 卖个萌(20 分)
91 0
PAT (Advanced Level) Practice - 1055 The World‘s Richest(25 分)
PAT (Advanced Level) Practice - 1055 The World‘s Richest(25 分)
101 0
ZOJ - Problem Set - 3985 String of CCPC
ZOJ - Problem Set - 3985 String of CCPC
84 0