题目描述

    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. c++ 链接mysql:error LNK2019: 无法解析的外部符号

    使用VS2012编译项目报错如下: error LNK2019: 无法解析的外部符号 _mysql_real_connect@32,该符号在函数 _main 中被引用 error LNK2019: 无 ...

  2. Hadoop集群中有哪些节点类型

  3. Leetcode144. Binary Tree Preorder Traversal二叉树的前序遍历

    给定一个二叉树,返回它的 前序 遍历. 示例: 输入: [1,null,2,3] 1 \ 2 / 3 输出: [1,2,3] 进阶: 递归算法很简单,你可以通过迭代算法完成吗? 递归: class S ...

  4. Google自带截图工具的使用

    转载自:http://chromecj.com/utilities/2017-12/859.html

  5. Idea代理设置与Java程序的代理设置

    最近在学习WebService的过程中,为了弄清楚发送和接收的包的数据结构,使用Fiddler抓取包的数据.开始先配置了Idea的代理设置,但执行Java代码发送请求时,依然无法在Fiddler中抓取 ...

  6. 【arc077f】AtCoder Regular Contest 074 F - Lotus Leaves

    题意 给定一个n*m的池塘,每个格子上可能有叶子. 从一个叶子出发,可以跳到相同行或相同列的叶子. 问至少去掉多少叶子,使得起点不能到达终点. \(n,m<=100\) 解法 很显然的最小割模型 ...

  7. 根据网站运行日志猜测的百度蜘蛛ip

    da大部分文章都是吵来吵去,不准确 所以就不参考那些沙雕的文章了,直接自己统计一个 123.125.71.117 123.125.71.58 220.181.108.115 220.181.108.1 ...

  8. IntelliJ IDEA 17 创建maven项目

    参考博客: https://yq.aliyun.com/articles/111053# 部署服务器时  没有Tomcat Server选项

  9. python基础--闭包and装饰器

    闭包函数:函数内部定义的函数:引用了外部变量但非全局变量 装饰器:有了闭包的概念再去理解装饰器就会相对容易一些.python装饰器本质上就是一个函数,它可以让其他函数在不需要做任何代码变动的前提下增加 ...

  10. 2019.10.20 csp-s模拟测试 lrd试题 反思总结

    赶进度赶进度,丢个代码两三句备注一下完事了. day1: 前面两道题没实际写代码怕印象不深所以描述一下大意. T1: 题目大意:给出两个数&.|.^的结果(可能只给出其中某一项或者某两项),求 ...