山东省赛J题:Contest Print Server
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的更多相关文章
- 2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server
		题目描述 In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source code ... 
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
		点击打开链接 2226: Contest Print Server Time Limit: 1 Sec Memory Limit: 128 MB Submit: 53 Solved: 18 [Su ... 
- zoj 4122 Triangle City 2019山东省赛J题
		题目链接 题意: 给出一个无向图,类似三角形的样子,然后给出边的权值,问找一条从第一个点到最后一个点的路径,要求每一条边只能走一次,并且权值和最大,点可以重复走. 思路: 首先观察这个图可以发现,所有 ... 
- 模拟 2013年山东省赛 J Contest Print Server
		题目传送门 /* 题意:每支队伍需求打印机打印n张纸,当打印纸数累计到s时,打印机崩溃,打印出当前打印的纸数,s更新为(s*x+y)%mod 累计数清空为0,重新累计 模拟简单题:关键看懂题意 注意: ... 
- sdutoj 2624 Contest Print Server
		http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2624 Contest Print Server ... 
- 2013年山东省赛F题 Mountain Subsequences
		2013年山东省赛F题 Mountain Subsequences先说n^2做法,从第1个,(假设当前是第i个)到第i-1个位置上哪些比第i位的小,那也就意味着a[i]可以接在它后面,f1[i]表示从 ... 
- HEX SDUT 3896 17年山东省赛D题
		HEX SDUT 3896 17年山东省赛D题这个题是从矩形的左下角走到右上角的方案数的变形题,看来我对以前做过的题理解还不是太深,或者是忘了.对于这种题目,直接分析它的性质就完事了.从(1,1)走到 ... 
- luogu 1327 数列排序 & 2017 ACM-ICPC 亚洲区(南宁赛区)网络赛 J题 循环节
		luogu 1327 数列排序 题意 给定一个数列\(\{an\}\),这个数列满足\(ai≠aj(i≠j)\),现在要求你把这个数列从小到大排序,每次允许你交换其中任意一对数,请问最少需要几次交换? ... 
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
		本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ... 
随机推荐
- SGU 111.Very simple problem
			题目大意: 求平方不大于n(n<=10^1000)的最大的数. 分析: 二分+高精度乘法 或者 高精度开方... ... 
- mongo db安装和php,python插件安装
			安装mongodb 1.下载,解压mongodb(下载解压目录为/opt) 在/opt目录下执行命令 wget fastdl.mongodb.org/linux/mongodb-linux-x86_6 ... 
- CPU风扇故障导致自动关机
			今天在使用电脑时,突然自动关机,重启后过一段时间又自动关机,于是打开机箱后盖,插上电源观察各个部位运行情况,发现CPU风扇不转,判断问题就是由于CPU温度太高了.于是换个风扇,再开机情况就正常了. 
- dede导航设置成单页面内容
			有时顶级导航可能就是一个单页面 如公司简介 联系我们等 方法一:直接在导航栏填写内容 常规设置 二高级选项设置模板 三 填写页面内容 四 模板页面调用 内容 可在栏目模板中用{dede:field.c ... 
- O-C浮点数转化整数
			1.简单粗暴,直接转化 float f = 1.5; int a; a = (int)f; NSLog("a = %d",a); 输出结果是1.(int)是强制类型转化,丢弃浮点数 ... 
- PLSQL Developer如何设置自动打开上次编辑的文件
			作为开发人员经常把sql语句保存到文件中以方便下次继续使用,问题是plsqlDev重启后每次都需要手工打开这个文件,好不方便: 以下设置是plsqlDev启动后自动打开上次编辑的文件. 选择配置> ... 
- C++类型转换运算符
			C++中提供4中类型转运算符,分别是:static_cast.dynamic_cast.reinterpret_cast和const_cast; 语法格式如下: 类型转换运算符 < type_i ... 
- Sort it all out
			poj1094:http://poj.org/problem?id=1094 题解(一位大神的分析) 一.当输入的字母全部都在前n个大写字母范围内时: (1)最终的图 可以排序: 在输入结束前如果能得 ... 
- Guess
			uvaLive4255:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&cat ... 
- PSoC电容式触摸感应技术
			PSoC是由Cypress半导体公司推出的具有数字和模拟混合处理能力的可编程片上系统芯片,某些系列的PSoC(如CY8C21X34系列),由于其内部配备的特殊资源,使得它可以很容易地实现电容式触摸感应 ... 
