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 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
 
题意:一开始打印机能打印s张,每一队有需要打印的纸张数目,如果该队打印完则到下一队,如果该队打印过程中纸张用完,则新的纸张会到达,而新纸张的数目是在原纸张本来数目上进行s=(s*x+y)%mod的运算,新纸张来后,打印序列必须从0开始,输出此过程
思路:直接模拟即可,但是当时由于题目没理解透,一直卡,而且0张输出也是允许的,坑啊
 
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; struct node
{
char name[30];
int num;
} team[105]; int main()
{
int t,n,s,x,y,mod,i,j,cnt;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d%d%d",&n,&s,&x,&y,&mod);
for(i = 1; i<=n; i++)
scanf("%s request %d pages",team[i].name,&team[i].num);
cnt = s;
for(i = 1; i<=n; i++)
{
while(1)
{
if(team[i].num<=cnt)
{
printf("%d pages for %s\n",team[i].num,team[i].name);
cnt-=team[i].num;
break;
}
else
{
printf("%d pages for %s\n",cnt,team[i].name);
s = (s*x+y)%mod;
if(s==0)
s = (s*x+y)%mod;
cnt = s;
}
}
}
printf("\n");
} return 0;
}

山东省赛J题:Contest Print Server的更多相关文章

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

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

  2. 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server

    点击打开链接 2226: Contest Print Server Time Limit: 1 Sec  Memory Limit: 128 MB Submit: 53  Solved: 18 [Su ...

  3. zoj 4122 Triangle City 2019山东省赛J题

    题目链接 题意: 给出一个无向图,类似三角形的样子,然后给出边的权值,问找一条从第一个点到最后一个点的路径,要求每一条边只能走一次,并且权值和最大,点可以重复走. 思路: 首先观察这个图可以发现,所有 ...

  4. 模拟 2013年山东省赛 J Contest Print Server

    题目传送门 /* 题意:每支队伍需求打印机打印n张纸,当打印纸数累计到s时,打印机崩溃,打印出当前打印的纸数,s更新为(s*x+y)%mod 累计数清空为0,重新累计 模拟简单题:关键看懂题意 注意: ...

  5. sdutoj 2624 Contest Print Server

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2624 Contest Print Server ...

  6. 2013年山东省赛F题 Mountain Subsequences

    2013年山东省赛F题 Mountain Subsequences先说n^2做法,从第1个,(假设当前是第i个)到第i-1个位置上哪些比第i位的小,那也就意味着a[i]可以接在它后面,f1[i]表示从 ...

  7. HEX SDUT 3896 17年山东省赛D题

    HEX SDUT 3896 17年山东省赛D题这个题是从矩形的左下角走到右上角的方案数的变形题,看来我对以前做过的题理解还不是太深,或者是忘了.对于这种题目,直接分析它的性质就完事了.从(1,1)走到 ...

  8. luogu 1327 数列排序 & 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 J题 循环节

    luogu 1327 数列排序 题意 给定一个数列\(\{an\}\),这个数列满足\(ai≠aj(i≠j)\),现在要求你把这个数列从小到大排序,每次允许你交换其中任意一对数,请问最少需要几次交换? ...

  9. [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛

    本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ...

随机推荐

  1. 分页插件jquery.simplePagination.js使用

    利用ecshop后台,利用插件更改分页显示样式遇到的问题,由于是利用Ajax获取数据进行页面数据更新?所以出现了以下情况: 初始化页面前 : 分页更新后: 点击后出现了分页插件内容消失, 原因:分页一 ...

  2. nodebb在阿里云主机部署过程

    1.在centos上安装nodejswget http://nodejs.org/dist/v0.8.9/node-v0.8.9.tar.gztar zxvf node-v0.8.9.tar.gzcd ...

  3. C语言学习笔记(二):指针的用法

    与其说指针是一种工具,不如先说指针是一种数据类型. -------------------------------------------------------------华丽的分割线------- ...

  4. WPF开发技术介绍

    本月做了一个小讲座,主要是WPF的开发技术介绍,由于是上班时间,去听的人不多,但对于自己来说至少是又巩固了Winform的知识,抽时间写一篇文章,在此分享给大家,有什么宝贵建议大家也可以提给我,谢谢. ...

  5. BZOJ 3107 二进制a+b

    Description 输入三个整数\(a, b, c\),把它们写成无前导\(0\)的二进制整数.比如\(a=7, b=6, c=9\),写成二进制为\(a=111, b=110, c=1001\) ...

  6. BZOJ 1208 宠物收养所

    Description 最近,阿Q开了一间宠物收养所.收养所提供两种服务:收养被主人遗弃的宠物和让新的主人领养这些宠物.每个领养者都希望领养到自己满意的宠物,阿Q根据领养者的要求通过他自己发明的一个特 ...

  7. [BZOJ 1084] [SCOI2005] 最大子矩阵 【DP】

    题目链接:BZOJ - 1084 题目分析 我看的是神犇BLADEVIL的题解. 1)对于 m = 1 的情况, 首先可能不取 Map[i][1],先 f[i][k] = f[i - 1][k];   ...

  8. 苦练SOC“基本功”启明星辰九年磨一剑

    2011年9月28日——10月31日,国内知名网络安全公司——启明星辰,作为协办方参与了51CTO在2011年举办的中国SOC安全管理平台市场应用现状调查. SOC(Security Operatio ...

  9. BZOJ 1030 [JSOI2007]文本生成器

    1030: [JSOI2007]文本生成器 Time Limit: 1 Sec  Memory Limit: 162 MBSubmit: 2624  Solved: 1087[Submit][Stat ...

  10. 数据结构(左偏树):HDU 1512 Monkey King

    Monkey King Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Tota ...