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

建议使用的浏览器:

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

3654:Draw Regular Polygon

题目描述
A regular polygon is a polygon whose all angles are equal in measure and all sides have the same length. Great mathematician Carl Friedrich Gauss had drawn a regular heptadecagon with only ruler and compass when he was 19. But today, we will not draw regular polygons that way. You had a circle of unit radius and some rulers, each can only measure certain distance, which equals to 2 sin (k*PI/n) , where n and k are known for each ruler. Thus you can measure an arc of 2k*PI/n on that circle with a ruler of parameters
n and k. Rulers can be used only to measure arcs on that circle, othe uses are forbidden. Each ruler can be used arbitrary many times. Now give you the parameters of r rulers, how many different regular polygons can you draw? Two regular polygons are said to be the same if they had the same number of sides, but may be differ in orientations. And a regular polygon should have at least 3 sides.
输入解释
Each test case begins with an integer r(1 <= r <=30) the number of rulers, on the first line. Then r lines followed, each line describes a ruler with two positive integers n(1 <= n <= 104) and k(1 <= k <= 104), indicate that ruler can measure a distance of 2 sin k*PI/n .
输出解释
Output two lines for each test case, the number of different regular polygons that can be drawn with the r rulers on the first line. Then output the possible numbers of sides of the polygons in ascending order on the second line, separate adjacent numbers by a single space. if the answer is greater than 16, only output the first 16 of them. If no polygons can be drawn, do not output the second line.
输入样例
2
2 1
3 1
1
4 2
1
5 2
输出样例
2
3 6
0
1
5
Pr
来自杭电HDUOJ的附加信息
Author Cauchy (Special thanks WJH)
Recommend lcy

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-3654

最后修改于 2020-10-25T23:05:40+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
6000/3000MS(Java/Others) 32768/32768K(Java/Others)