题目描述

    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 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.

示例输入

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

示例输出

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

分析:算是一简单题,但是题目比较绕人,英文看的云里雾里的,只能通过不断的提交验证自己的猜想(个人WA了两次),直到AC之后再看就明了了:-
#include<stdio.h>
int main(void)
{
int cases, n, s, x, y, mod, p, count;
char team_name[];
char str[]; // 过滤输入字符串"request"和"page" scanf("%d", &cases);
while(cases--)
{
scanf("%d%d%d%d%d", &n, &s, &x, &y, &mod); count = ;
while(n--)
{
scanf("%s%s%d%s", team_name, str, &p, str);
if(count+p <= s)
printf("%d pages for %s\n", p, team_name);
else
{
printf("%d pages for %s\n", s-count, team_name);
while()
{
s = (s*x+y) % mod;
if(p <= s)
{
printf("%d pages for %s\n", p, team_name);
count = ;
break;
}
else
{
printf("%d pages for %s\n", s, team_name);
}
}
} count += p;
} printf("\n");
} return ;
}
count 变量挪了下位置同样AC:
#include<stdio.h>
int main(void)
{
int cases, n, s, x, y, mod, p, count;
char team_name[];
char str[]; // 过滤输入字符串"request"和"page" scanf("%d", &cases);
while(cases--)
{
scanf("%d%d%d%d%d", &n, &s, &x, &y, &mod); count = ;
while(n--)
{
scanf("%s%s%d%s", team_name, str, &p, str);
count += p;
if(count <= s)
printf("%d pages for %s\n", p, team_name);
else
{
printf("%d pages for %s\n", s-count+p, team_name);
while()
{
s = (s*x+y) % mod;
if(p <= s)
{
printf("%d pages for %s\n", p, team_name);
count = p;
break;
}
else
{
printf("%d pages for %s\n", s, team_name);
}
}
} } printf("\n");
} return ;
}

2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server的更多相关文章

  1. 2013年山东省第四届ACM大学生程序设计竞赛E题:Alice and Bob

    题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynom ...

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

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

  3. Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)

    Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...

  4. sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛

    Mountain Subsequences 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There ...

  5. 2013年山东省第四届ACM大学生程序设计竞赛 Alice and Bob

      Alice and Bob Time Limit: 1000ms   Memory limit: 65536K 题目描述 Alice and Bob like playing games very ...

  6. 山东省第四届ACM大学生程序设计竞赛解题报告(部分)

    2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...

  7. angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...

  8. UPC 2224 / “浪潮杯”山东省第四届ACM大学生程序设计竞赛 1008 Boring Counting 主席树

    Problem H:Boring Counting Time Limit : 6000/3000ms (Java/Other)   Memory Limit : 65535/32768K (Java/ ...

  9. 2014年山东省第五届ACM大学生程序设计竞赛F题:Full Binary Tree

    题目描述 In computer science, a binary tree is a tree data structure in which each node has at most two ...

随机推荐

  1. MySQL双机热备份配置

    双机热备份,即能够把主数据库中所有的数据同时写到备份的数据库中,从而实现MySQL数据库的热备份. MySQL Replication是MySQL提供的一种主从备份的机制,并且整个复制备份过程是异步进 ...

  2. Django项目:CRM(客户关系管理系统)--17--09PerfectCRM实现King_admin显示注册表的内容

    {#table_data_list.html#} {## ————————08PerfectCRM实现King_admin显示注册表的字段表头————————#} {% extends 'king_m ...

  3. TZ_16_Vue定义全局组件和局部组件

    1.定义全局组件 我们通过Vue的component方法来定义一个全局组件. <div id="app"> <!--使用定义好的全局组件--> <co ...

  4. nginx的四个基本功能

    Nginx能做什么 1.反向代理2.负载均衡3.HTTP服务器(包含动静分离)4.正向代理 以上就是做网站小编了解到的Nginx在不依赖第三方模块能处理的事情,下面详细说明每种功能怎么做 1.反向代理 ...

  5. 洛谷P1970 [NOIP2013提高组Day2T2] 花匠

    P1970 花匠 题目描述 花匠栋栋种了一排花,每株花都有自己的高度.花儿越长越大,也越来越挤.栋栋决定 把这排中的一部分花移走,将剩下的留在原地,使得剩下的花能有空间长大,同时,栋栋希 望剩下的花排 ...

  6. 洛谷P1621 集合 [2017年6月计划 数论13]

    P1621 集合 题目描述 现在给你一些连续的整数,它们是从A到B的整数.一开始每个整数都属于各自的集合,然后你需要进行一下的操作: 每次选择两个属于不同集合的整数,如果这两个整数拥有大于等于P的公共 ...

  7. Sublime Text Version 3.2.1(Build 3207)注册

    Sublime Text Version 3.2.1, Build 3207 一. host添加地址 C:\Windows\System32\drivers\etc\hosts 127.0.0.1 l ...

  8. 基于spring-boot的测试桩设计-添加配置文件(properties)

    编写测试时,有些内容可以放到配置文件中. 第一步:新增配置文件 conf.properties 第二步:编写配置文件类 MockConf package mock.mockdemo.conf; imp ...

  9. LUOGU P2827 蚯蚓 (noip 2016)

    传送门 解题思路 第一眼以为是一个二叉堆,直接上优先队列60分...后来听ztz11说有单调性,新加入的蚯蚓一定比原先在的蚯蚓长度长,开三个队列,分别放原先的长度,切掉后大的那一半,切掉后小的那一半. ...

  10. 第十章—DOM(0)—NODE类型

    DOM1定义了一个node接口,该接口由DOM的所有节点类型实现. 所有的节点都存在这样或那样的关系.在HTML中,head,body可以看出是html的子元素,html是head,body的父元素, ...