模拟 2013年山东省赛 J Contest Print Server
/*
题意:每支队伍需求打印机打印n张纸,当打印纸数累计到s时,打印机崩溃,打印出当前打印的纸数,s更新为(s*x+y)%mod
累计数清空为0,重新累计
模拟简单题:关键看懂题意
注意:打印机一张一张纸打印,当某支队伍打印完正好累计到s时,要输出0,坑点!
*/
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <cstring>
using namespace std; int cnt[];
char ss[][]; int main(void) //J Contest Print Server
{
//freopen ("J.txt", "r", stdin); int t;
while (scanf ("%d", &t) == )
{
while (t--)
{
int n, s, x, y, mod;
scanf ("%d%d%d%d%d", &n, &s, &x, &y, &mod); for (int i=; i<=n; ++i)
scanf ("%s request %d pages", &ss[i], &cnt[i]); int num = , j;
int ok = ;
for (int i=; i<=n; ++i)
{
if (ok == ) printf ("%d pages for %s\n", , ss[i]);
ok = ;
for (j=; j<=cnt[i]; ++j)
{
num++;
if (num == s)
{
printf ("%d pages for %s\n", j, ss[i]);
s = (s * x + y) % mod;
if (s == ) s = (s * x + y) % mod;
num = ; break;
}
}
if (j < cnt[i]) i--;
else if (j == cnt[i]) ok = ;
else printf ("%d pages for %s\n", cnt[i], ss[i]);
}
if (t) puts ("");
} } return ;
} /*
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
*/
模拟 2013年山东省赛 J Contest Print Server的更多相关文章
- 山东省赛J题:Contest Print Server
Description In ACM/ICPC on-site contests ,3 students share 1 computer,so you can print your source c ...
- 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 ...
- 2013年山东省赛F题 Mountain Subsequences
2013年山东省赛F题 Mountain Subsequences先说n^2做法,从第1个,(假设当前是第i个)到第i-1个位置上哪些比第i位的小,那也就意味着a[i]可以接在它后面,f1[i]表示从 ...
- sdutoj 2624 Contest Print Server
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2624 Contest Print Server ...
- [原]sdut2624 Contest Print Server (大水+大坑)山东省第四届ACM省赛
本文出自:http://blog.csdn.net/svitter 原题:http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&am ...
- 2013成都网络赛 J A Bit Fun(水题)
A Bit Fun Time Limit: 5000/2500 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total S ...
- HDU 4800/zoj 3735 Josephina and RPG 2013 长沙现场赛J题
第一年参加现场赛,比赛的时候就A了这一道,基本全场都A的签到题竟然A不出来,结果题目重现的时候1A,好受打击 ORZ..... 题目链接:http://acm.hdu.edu.cn/showprobl ...
- 位运算 2013年山东省赛 F Alice and Bob
题目传送门 /* 题意: 求(a0*x^(2^0)+1) * (a1 * x^(2^1)+1)*.......*(an-1 * x^(2^(n-1))+1) 式子中,x的p次方的系数 二进制位运算:p ...
随机推荐
- 教你如何---构建良好的windows程序(初学者必看)
一使用菜单栏和工具栏 1.菜单栏和工具栏有什么作用和优点: 通过菜单栏把应用程序的功能进行分组,能够方便用户查找和使用,下图所示的菜单栏包含的每一项都是顶层菜单项,顶层菜单项下的选项称为”子菜单”或” ...
- Windbg对过滤驱动DriverEntry函数下断点技巧
方法1: 1> 先用DeviceTree.exe查看指定的过滤驱动的Load Address(加载地址) 2> 再用LordPE.EXE查看指定过滤驱动文件的入口点地址 3> 计算过 ...
- [Effective JavaScript 笔记]第31条:使用Object.getPrototypeOf函数而不要使用__proto__属性
ES5引入Object.getPrototypeOf函数作为获取对象原型的标准API,但由于之前的很多js引擎使用了一个特殊的__proto__属性来达到相同的目的.但有些浏览器并不支持这个__pro ...
- poj2632 模拟
Crashing Robots Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 8388 Accepted: 3631 D ...
- 解决android:theme="@android:style/Theme.NoDisplay" 加入这句话后程序不能运行
原因: 原来用的是ActionBarActivity,继承自 ActionBarActivity的类必须指定固定的集中Theme风格,而这些 Theme 风格是需要导入V7中的 appcompat L ...
- postgresql 函数demo
create or replace function refresh_product_usage() returns void as $$ declare rec record; sub_rec re ...
- Windows下使用命令行设置ip地址的DNS服务器
使用命令行或者编写bat批处理设置网络连接的IP地址以及DNS服务器地址有时候会比手动更加方便,IP地址和DNS的设置一般是配合的,常用到的几个状态是: 1.IP地址动态获取,DNS也动态 2.IP地 ...
- linux下emacs配置文件
1:安装.在ubuntu下使用命令 sudo apt-get install emacs,即可,我使用的是ubuntu的10.04的版本,在里面使用了据说是163的2个源. 1.1:如何更新快速的源, ...
- HDU 5795 A Simple Nim (博弈) ---2016杭电多校联合第六场
A Simple Nim Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Tota ...
- jsp url传值乱码
<Connector port="8080" maxHttpHeaderSize="8192" minProcessors="10" ...