2013年山东省第四届ACM大学生程序设计竞赛J题:Contest Print Server
题目描述
输入
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.
输出
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的更多相关文章
- 2013年山东省第四届ACM大学生程序设计竞赛E题:Alice and Bob
题目描述 Alice and Bob like playing games very much.Today, they introduce a new game. There is a polynom ...
- 2013年山东省第四届ACM大学生程序设计竞赛-最后一道大水题:Contest Print Server
点击打开链接 2226: Contest Print Server Time Limit: 1 Sec Memory Limit: 128 MB Submit: 53 Solved: 18 [Su ...
- Alice and Bob(2013年山东省第四届ACM大学生程序设计竞赛)
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very m ...
- sdut Mountain Subsequences 2013年山东省第四届ACM大学生程序设计竞赛
Mountain Subsequences 题目描述 Coco is a beautiful ACMer girl living in a very beautiful mountain. There ...
- 2013年山东省第四届ACM大学生程序设计竞赛 Alice and Bob
Alice and Bob Time Limit: 1000ms Memory limit: 65536K 题目描述 Alice and Bob like playing games very ...
- 山东省第四届ACM大学生程序设计竞赛解题报告(部分)
2013年"浪潮杯"山东省第四届ACM大学生程序设计竞赛排名:http://acm.upc.edu.cn/ranklist/ 一.第J题坑爹大水题,模拟一下就行了 J:Contes ...
- angry_birds_again_and_again(2014年山东省第五届ACM大学生程序设计竞赛A题)
http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2877 题目描述 The problems ca ...
- UPC 2224 / “浪潮杯”山东省第四届ACM大学生程序设计竞赛 1008 Boring Counting 主席树
Problem H:Boring Counting Time Limit : 6000/3000ms (Java/Other) Memory Limit : 65535/32768K (Java/ ...
- 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 ...
随机推荐
- PHP之文件的锁定、上传与下载的方法
1.文件锁定 现在都在讲究什么分布式.并发等,实际上文件的操作也是并发的,在网络环境下,多个用户在同一时刻访问页面,对同一服务器上的同一文件进行着读取,如果,这个用户刚好读到一半,另一个用户就写入了消 ...
- Django项目:CRM(客户关系管理系统)--32--24PerfectCRM实现King_admin自定义操作数据
#admin.py # ————————01PerfectCRM基本配置ADMIN———————— from django.contrib import admin # Register your m ...
- SmartSQL
- table使用display:block时会多出一条边框
在静态页面中添加一个table,然后设置table的显示隐藏,当使用display:block显示table时出现了如下情况,详情请点击链接: http://jsbin.com/pinovorahu/ ...
- LR自带网站飞机订票系统 启动
LR自带的网站:飞机订票系统 可是如何启动自带的网站呢?? 一.启动服务:开始-所有程序--HP Software-HP LoadRunner-Samples-Web-Start Web Server ...
- SpringBoot-(10)配置虚拟路径-指定外部路径文件夹存取文件
参考:https://blog.csdn.net/feng2147685/article/details/95623135 package com.online.director; import or ...
- Spring松耦合示例(转)& IOC
Spring松耦合示例 轻松学习Spring<一> IoC容器和Dependency Injection模式 最近公司需要,项目中要用到Spring和Ibatis.趁着过年好好学习学习.I ...
- java图形验证码生成工具类及web页面校验验证码
最近做验证码,参考网上案例,发现有不少问题,特意进行了修改和完善. 验证码生成器: import javax.imageio.ImageIO; import java.awt.*; import ja ...
- Apache-Shiro分布式环境配置(与redis集成)(转)
原文戳我 前段时间项目要用到权限控制的相关模块,经过讨论决定采用Apache下面的Shiro开源框架进行身份校验与权限控制,因项目需部署在集群环境下,所以需要分布式的支持,故配置了Redis作为权限数 ...
- GitHub and Git
book:https://git-scm.com/book/zh/v2 Git使用简易指南:https://www.bootcss.com/p/git-guide