UVa 637 - Booklet Printing
题目:模拟输出n页书的装订打印状态。
分析:模拟。页数为(n+3)/ 4,仅仅有n不超过半篇时会输出半篇。
说明:好多曾经做过的题目(⊙_⊙)。
#include <cstdlib>
#include <cstring>
#include <cstdio> int book[30][4]; int main()
{
int n;
while (~scanf("%d",&n) && n) {
int page = (n+3)/4;
memset(book ,0 ,sizeof(book));
int count = 1;
for (int i = 1 ; i <= page ; ++ i) {
book[i][1] = count ++;
if (count > n) break;
book[i][2] = count ++;
if (count > n) break;
}
if (count <= n)
for (int i = page ; i >= 1 ; -- i) {
book[i][3] = count ++;
if (count > n) break;
book[i][0] = count ++;
if (count > n) break;
} printf("Printing order for %d pages:\n",n);
for (int i = 1 ; i <= page ; ++ i) {
if (book[i][0] || book[i][1]) {
printf("Sheet %d, front: ",i);
if (book[i][0]) printf("%d, ",book[i][0]);
else printf("Blank, ");
if (book[i][1]) printf("%d\n",book[i][1]);
else printf("Blank\n");
}
if (book[i][2] || book[i][3]) {
printf("Sheet %d, back : ",i);
if (book[i][2]) printf("%d, ",book[i][2]);
else printf("Blank, ");
if (book[i][3]) printf("%d\n",book[i][3]);
else printf("Blank\n");
}
}
}
return 0;
}
UVa 637 - Booklet Printing的更多相关文章
- Booklet Printing[HDU1117]
Booklet Printing Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) ...
- ZOJ 1178 Booklet Printing
原题链接 题目大意:书本印刷都是用大开的纸张对折.比如一个册子一共4页,为了方便装订,外侧印刷1.4页,内侧印刷2.3页,这样对折之后就可以按照正常阅读习惯翻页了.此题目的就是给出书的总页数,要求计算 ...
- ACM学习
转:ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. US ...
- (转载)ACM训练计划,先过一遍基础再按此拼搏吧!!!!
ACM大量习题题库 ACM大量习题题库 现在网上有许多题库,大多是可以在线评测,所以叫做Online Judge.除了USACO是为IOI准备外,其余几乎全部是大学的ACM竞赛题库. USACO ht ...
- POJ 题目分类(转载)
Log 2016-3-21 网上找的POJ分类,来源已经不清楚了.百度能百度到一大把.贴一份在博客上,鞭策自己刷题,不能偷懒!! 初期: 一.基本算法: (1)枚举. (poj1753,poj2965 ...
- HDU——PKU题目分类
HDU 模拟题, 枚举1002 1004 1013 1015 1017 1020 1022 1029 1031 1033 1034 1035 1036 1037 1039 1042 1047 1048 ...
- (转)POJ题目分类
初期:一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. (4)递推. ...
- poj分类
初期: 一.基本算法: (1)枚举. (poj1753,poj2965) (2)贪心(poj1328,poj2109,poj2586) (3)递归和分治法. ( ...
- 转载 ACM训练计划
leetcode代码 利用堆栈:http://oj.leetcode.com/problems/evaluate-reverse-polish-notation/http://oj.leetcode. ...
随机推荐
- CentOS下NTP安装配置
安装yum install ntp 配置文件 /etc/ntp.confrestrict default kod nomodifynotrap nopeer noqueryrestrict -6 ...
- plsql例子
create or replace procedure find_difference(db_link in varchar2) is /* 比对两套环境建表脚本差异,以224环境为主 当前环境,db ...
- HDU 4725 The Shortest Path in Nya Graph(spfa+虚拟点建图)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4725 题目大意:有n层,n个点分布在这些层上,相邻层的点是可以联通的且距离为c,还有额外给出了m个条边 ...
- Redis实战(七)
修改数据 C#语言修改Redis示例. 1.通过key修改单个value using (var redisClient = RedisManager.GetClient()) { var user = ...
- ubuntu怎么连接centos远程桌面
1.系统软件设置CentOS端:查看是否安装了vnc软件# rpm -q vnc vnc-serverpackage vnc is not installedvnc-server-4.1.2-14.e ...
- GNU Wget 1.19.4 for Windows
资源地址:https://eternallybored.org/misc/wget/ 然后将工具目录加入环境变量
- 转:Meltdown Proof-of-Concept
转:https://github.com/IAIK/meltdown Meltdown Proof-of-Concept What is the difference between Meltdown ...
- 【leetcode】 21. Merge Two Sorted Lists
题目描述: Merge two sorted linked lists and return it as a new list. The new list should be made by spli ...
- python笔记五:IO与文件
1.python IO: Python提供了两个内置函数从标准输入读入一行文本,默认的标准输入是键盘: 1)raw_input([prompt]) 函数从标准输入读取一个行,并返回一个字符串 2 ...
- centos7 更改时区
Linux 系统(我特指发行版, 没说内核) 下大部分软件的风格就是不会仔细去考虑向后 的兼容性, 比如你上个版本能用这种程序配置, 没准到了下一个版本, 该程序已经不见了. 比如 sysvinit ...