当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

1126: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

该题目包含在题集 ACM赛制

共提交 1

通过率 0.0%
时间上限 内存上限
1000 MS 128 MB