F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Draw Regular Polygon

Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 394    Accepted Submission(s): 74


Problem Description
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.
 

Input
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
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.
 

Sample Input
2 2 1 3 1 1 4 2 1 5 2
 

Sample Output
2 3 6 0 1 5 Pr
 

Author
Cauchy (Special thanks WJH)
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-24 16:44:35, Gzip enabled