算法题:Patterns and Pictures
来源:互联网 发布:词根词缀字典 知乎 编辑:程序博客网 时间:2024/05/18 02:11
前言:
这道题是:2008 ACM ICPC South Central USA Regional Programming Contest 的比赛试题,也是2016年10月15日链家网的笔试题。
题目链接:
Patterns and Pictures
题目描述:
Fabrics often have repeating patterns on them, such as a tessellation of carrots and bats.
A given image, such as a carrot in the above example, takes up a certain number of square inches on the fabric. In addition, a piece of fabric with more than one image will have those images in some sort of simple integral ratio, such as 3 carrots for every 2 bats. One instance of images in the given ratio is considered a full set.
Fabrics are sold by the square yard (and, for those of you who have forgotten, there are 36 inches to the yard). Given a collection of images, their sizes, and the ratios in which they occur, what is the maximum number of full sets that could possibly appear on one, two, and three square yards of patterned fabric?
(Note that this maximum implies totally arbitrary shapes and placements for the images, which may be different for the three lengths of fabric; the particulars of the layout are irrelevant for the purposes of the problem.)
输入:
Input to this problem will begin with a line containing a single integer N (1 ≤ N ≤ 100) indicating the number of data sets. Each data set consists of the following components:A line containing a single integer I (1 ≤ I ≤ 10) indicating the number of images in a particular pattern;
A series of I lines, each with two integers S, R (1 ≤ S ≤ 1000; 1 ≤ R ≤ 100) separated by spaces representing the images. S is the number of square inches that the image occupies; R is the count of the images contained in a full set.输出:
For each data set, print “A B C”, where A is the maximum number of full sets that could possibly appear on one square yard of fabric, B is the maximum number of full sets that could possibly appear on two square yards of fabric, and C is the maximum number of full sets that could possibly appear on three square yards of fabric.样例输入:
1
2
15 3
17 2样例输出:
16 32 49
题目解释:
这个题目最吓人的地方是题干描述太多了,这么多,其实题目的意思是:一个窗帘上有很多图案,图案还有可能有多种,多种图案按照一定的比例组合图案,给定一个窗帘的面积,然后问图案最多有多少?
解题思路:
窗帘总面积除图案组合的面积就是最大的个数。
AC代码:
#include <stdio.h>#define ALL 1296int main(){ int n; scanf("%d", &n); while(n--){ int i; scanf("%d", &i); int sum = 0; while(i--) { int s; int r; scanf("%d %d", &s, &r); sum += (s * r); } printf("%d %d %d\n", (ALL / sum), ((ALL * 2) / sum), ((ALL * 3) / sum)); } return 0;}
- 算法题:Patterns and Pictures
- HOJ 2769 Patterns and Pictures
- APidemo 学习 PolyToPoly DrawPoints Pictures Patterns PathFillTypes
- pictures
- Pictures
- 拍照片和拍影片(Taking Pictures and Movies)
- Ajax Patterns and Best Practices
- Use Cases Patterns and Blueprints
- Design rules and patterns (MVC)
- SharePoint Patterns and Practices 简介
- Principles of Service Design: Service Patterns and Anti-Patterns
- Local Binary Patterns LBP算法
- Pictures Test
- my pictures
- joking pictures
- The Strategy, Template Method, and Bridge Patterns
- Software Architecture : Organizational Principles and Patterns
- 《Agile Software Development: Principles, Patterns, and Practices》
- json-c的树型封装(json-tree)
- 多行文本溢出显示省略号(…)全攻略
- sql聚集索引深入浅出讲解
- (1)行列式的定义
- 源码-Oracle数据库管理-第十二章-使用PL/SQL创建Oracle程序-Part 4(PL/SQL语言概览)
- 算法题:Patterns and Pictures
- 1066. Root of AVL Tree (25)解题报告
- IntelliJ IDEA 14 注册码
- opencv get pgm picture
- GO声明变量和常量的方法
- 设计模式之桥接模式
- JSTL常用标签练习--i18N标签库
- Python如何将百分号的字符转成数字
- 视频播放