Pro.ID21639 TitleUnion Set Title链接http://10.20.2.8/oj/exercise/problem?problem_id=21639 AC1 Submit6 Ratio16.67% 时间&空间限制描述There are a number of sets. Each set is made up of integers and has the form { x | x = a + k * d, a = 0, 1, 2, ... and x ≤ b ). That is to say, a set is decided by constants a, b and d. Your task is to calculate the union set of given sets. Just tell me the size of the union set. 输入There are multiple test cases. For each test case, there is an integer number n on the first line indicating the number of sets. 0 ≤ n ≤ 10. Each of the following n lines contains three integers ai, bi and di. All integers are 32-bit signed integers and 0 ≤ di ≤ 30 . Input is terminated by n=0. 输出Description There are a number of sets. Each set is made up of integers and has the form { x | x = a + k * d, a = 0, 1, 2, ... and x ≤ b ). That is to say, a set is decided by constants a, b and d. Your task is to calculate the union set of given sets. Just tell me the size of the union set. Input There are multiple test cases. For each test case, there is an integer number n on the first line indicating the number of sets. 0 ≤ n ≤ 10. Each of the following n lines contains three integers ai, bi and di. All integers are 32-bit signed integers and 0 ≤ di ≤ 30 . Input is terminated by n=0. Output For each test case, output the size of the union set on a single line. Sample Input 2 Sample Output 3 Source 样例输入2 样例输出3 作者 |