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 ...
随机推荐
- HYSBZ 1015/BZOJ1015 星球大战starwar
Description 很久以前,在一个遥远的星系,一个黑暗的帝国靠着它的超级武器统治者整个星系.某一天,凭着一个偶然的机遇,一支反抗军摧毁了帝国的超级武器,并攻下了星系中几乎所有的星球.这些星球通过 ...
- Leetcode147. Insertion Sort List对链表进行插入排序
对链表进行插入排序. 从第一个元素开始,该链表可以被认为已经部分排序(用黑色表示). 每次迭代时,从输入数据中移除一个元素(用红色表示),并原地将其插入到已排好序的链表中. 插入排序算法: 插入排序是 ...
- TZ_05_Spring_Transaction的纯注解开发
1.数据库配置 jdbcConfiguation.java 1>使用Spring的EL表达式配合@Value()注解 @Value("${jdbc.Driver}") pri ...
- swiper 报错 ‘ Can't find variable: Dom7’
一般报这个错是因为浏览器兼容问题,例如低版本的IE 现在通过npm install swiper 安装的版本都是4.x的 我的解决方法就是安装低版本的swiper, npm install swipe ...
- c#还有一点不太明白,既然开启了线程为何还要委托呢?
2013-07-15 09:33threadroc | 浏览 1611 次 既然开启了线程为何还要委托呢?,开启线程本身不就是委托吗?为何委托要显示声明呢?Thread thread = new Th ...
- flask的基本操作
常用的SQLAlchemy字段类型 # coding:utf-8 from flask import Flask from flask_sqlalchemy import SQLAlchemy app ...
- python 关于如何把json文件里面的多条数据删除,只保留自己需要的条目
参考博客: https://www.cnblogs.com/bigberg/p/6430095.html https://zhidao.baidu.com/question/7173208338528 ...
- 2019.8.14 NOIP模拟测试21 反思总结
模拟测试20的还没改完先咕着 各种细节问题=错失190pts T1大约三分钟搞出了式子,迅速码完,T2写了一半的时候怕最后被卡评测滚去交了,然后右端点没有初始化为n…但是这样还有80pts,而我后来还 ...
- Nginx 函数解析之ngx_http_get_forwarded_addr_internal
static ngx_int_t ngx_http_get_forwarded_addr_internal(ngx_http_request_t *r, ngx_addr_t *addr, u_cha ...
- P1561 [USACO12JAN]爬山Mountain Climbing
P1561 [USACO12JAN]爬山Mountain Climbing 题目描述 Farmer John has discovered that his cows produce higher q ...