Pipe Fitters
Time Limit: 1000MS Memory Limit: 10000K
Total Submissions: 1889 Accepted: 854

Description

Filters, or programs that pass “processed” data through in some changed form, are an important class of programs in the UNIX operating system. A pipe is an operating system concept that permits data to “flow” between processes (and allows filters to be chained together easily.)
This problem involves maximizing the number of pipes that can be fit into a storage container (but it’s a pipe fitting problem, not a bin packing problem).
A company manufactures pipes of uniform diameter. All pipes are stored in rectangular storage containers, but the containers come in several different sizes. Pipes are stored in rows within a container so that there is no space between pipes in any row (there may be some space at the end of a row), i.e., all pipes in a row are tangent, or touch. Within a rectangular cross-section, pipes are stored in either a grid pattern or a skew pattern as shown below: the two left-most cross-sections are in a grid pattern, the two right-most cross-sections are in a skew pattern.

Note that although it may not be apparent from the diagram, there is no space between adjacent pipes in any row. The pipes in any row are tangent to (touch) the pipes in the row below (or rest on the bottom of the container). When pipes are packed into a container, there may be “left-over” space in which a pipe cannot be packed. Such left-over space is packed with padding so that the pipes cannot settle during shipping.

Input

The input is a sequence of cross-section dimensions of storage containers. Each cross-section is given as two real values on one line separated by white space. The dimensions are expressed in units of pipe diameters. All dimensions will be less than 128. Note that a cross section with dimensions a*b can also be viewed as a cross section with dimensions b * a.

Output

For each cross-section in the input, your program should print the maximum number of pipes that can be packed into that cross section. The number of pipes is an integer – no fractional pipes can be packed. The maximum number is followed by the word “grid” if a grid pattern results in the maximal number of pipes or the word “skew” if a skew pattern results in the maximal number of pipes. If the pattern doesn’t matter, that is the same number of pipes can be packed with either a grid or skew pattern, then the word “grid” should be printed.

Sample Input

3 3
2.9 10
2.9 10.5
11 11

Sample Output

9 grid
29 skew
30 skew
126 skew

Source

Duke Internet Programming Contest 1993,UVA 121

问题链接:UVA121 POJ1319 HDU1621 Pipe Fitters
问题简述:(略)
问题分析:计算几何问题,不解释。
程序说明:(略)
参考链接:(略)
题记:程序代码要尽量写得简单。

AC的C++语言程序如下:

/* UVA121 POJ1319 HDU1621 Pipe Fitters */#include <iostream>
#include <cmath>
#include <cstdio>using namespace std;const double DR = sqrt(3) / 2;inline int getgrid(double w, double h)
{return floor(w) * floor(h);
}int getskew(double w, double h)
{int w1 = floor(w), w2 = floor(w - 0.5);int ret = 0, even = 1;double r = 0;for (;;) {if (r + 1 > h) break;r += DR;ret += even ? w1 : w2;even = 1 - even;}return ret;
}int main()
{double w, h;while (~scanf("%lf%lf", &w, &h)) {int grid = getgrid(w, h);int skew = max(getskew(h, w), getskew(w, h));if (grid >= skew) printf("%d grid\n", grid);else printf("%d skew\n", skew);}return 0;
}

UVA121 POJ1319 HDU1621 Pipe Fitters【计算几何】相关推荐

  1. HOJ题目分类//放这儿没事刷刷学算法!嘻嘻!

    各种杂题,水题,模拟,包括简单数论. 1001 A+B 1002 A+B+C 1009 Fat Cat 1010 The Angle 1011 Unix ls 1012 Decoding Task 1 ...

  2. POJ 超详细分类

    POJ 各题算法 1000    A+B Problem            送分题     49%    2005-5-7 1001    Exponentiation         高精度   ...

  3. π-Algorithmist分类题目(1)

    原题网站:Algorithmist,http://www.algorithmist.com/index.php/Main_Page π-Algorithmist分类题目(1) Sorting UVAL ...

  4. 杭电oj题目题型分类(转)

    1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 ...

  5. HDOJ题目分类大全

    版权声明:本文为博主原创文章,欢迎转载,转载请注明本文链接! https://blog.csdn.net/qq_38238041/article/details/78178043 杭电里面有很多题目, ...

  6. HDU题目分类大全【大集合】

    基础题: 1000.1001.1004.1005.1008.1012.1013.1014.1017.1019.1021.1028.1029.  1032.1037.1040.1048.1056.105 ...

  7. POJ前面的题目算法思路【转】

    1000 A+B Problem 送分题 49% 2005-5-7 1001 Exponentiation 高精度 85% 2005-5-7 1002 487-3279 n/a 90% 2005-5- ...

  8. UVa Online Judge 工具網站

    UVa Online Judge 工具網站 转自http://www.csie.ntnu.edu.tw/~u91029/uva.html Lucky貓的ACM園地,Lucky貓的 ACM 中譯題目 M ...

  9. 杭电OJ题目分类(转载)

    1001 整数求和 水题 1002 C语言实验题--两个数比较 水题 1003 1.2.3.4.5... 简单题 1004 渊子赛马 排序+贪心的方法归并 1005 Hero In Maze 广度搜索 ...

最新文章

  1. 将输入字符串t中从第m个字符开始的全部字符复制到字符串s中_leetcode第32双周赛第二题leetcode1540. K 次操作转变字符串...
  2. 《MongoDB管理与开发精要》——1.4节本章小结
  3. Oculus Connect 4 演讲——留住用户和建立联系(视频) | 【翻译】
  4. 硬核!一套基于SpringBoot + Vue 的开源物联网智能家居系统!
  5. VMware中CentOS设置静态IP
  6. linux操作系统中的netstat命令查看端口状态的使用和window操作系统查看端口号
  7. python calu()函数_酚酞指示剂是一类什么物质,它在PH=10时是什么颜色呢(     )...
  8. 销毁Session和清空指定的属性
  9. Java性能调优的11个实用技巧
  10. 硬件入门之PCB设计注意事项
  11. 求两个数的最大公约数和最小公倍数
  12. GIS招聘 | 甘肃、海南、辽宁、内蒙古地震局
  13. 使用 Laragon 在 Windows 中快速搭建 Laravel 本地开发环境 (转)
  14. 关于Too many re-renders. React limits the number of renders to prevent an infinite loop.的解决方案
  15. NA公链(Nirvana)NAC公链独步公链江湖
  16. CreateProcess创建一个隐藏进程
  17. 苏州将统一发放多功能“市民卡”
  18. 物体结构图,快速图解物体内部结构
  19. 智能家居设备安全分析技术综述
  20. Nirvana NA公链 NAC公链的两面观

热门文章

  1. python模块讲解_python中常用模块详解一
  2. TLS 1.3套件TLS_CHACHA20_POLY1305_SHA256:TLS_AES_256_GCM_SHA384:TLS_AES_128_GCM_SHA256
  3. [草稿]几款硬盘数据共享产品技术选型
  4. Unity直接导出Android Apk包环境配置
  5. PhoneGap在Android上的插件开发方法介绍
  6. C#图片处理之: 锐化
  7. java类的聚合 组合定义_Java里组合和聚合的概念及其实现
  8. 软件测试python测试步骤_软件测试员必备基础:3分钟带你入门自动化测试!
  9. HelloKafka入门 helloKafka
  10. python配什么数据库_python中常见数据库有哪些