21639_UnionSe

2022-5-16 18:20| 发布者: Hocassian| 查看: 23| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505712194800-Problem List-采集的数据-后羿采集器.html

Pro.ID

21639

Title

Union Set

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21639

AC

1

Submit

6

Ratio

16.67%

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Others)
  • 描述

    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 xb ). 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 xb ). 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
    1 3 2
    2 4 3
    0

    Sample Output

    3

    Source

    样例输入

    2
    1 3 2
    2 4 3
    0

    样例输出

    3

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部