10143_ControllingCompanies

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

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

Pro.ID

10143

Title

Controlling Companies

Title链接

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

AC

36

Submit

153

Ratio

23.53%

时间&空间限制

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

    Some companies are partial owners of other companies because they have acquired part of their total shares of stock. For example, Ford owns 12% of Mazda. It is said that a company A controls company B if at least one of the following conditions is satisfied:

    • Company A = Company B

    • Company A owns more than 50% of Company B

    • Company A controls K ( K ≥ 1 ) companies denoted C1, ..., CK with each company Ci owning xi% of company B and x1 + .... + xK > 50%.

    Given a list of triples (i, j, p) which denote company i owning p% of company j, calculate all the pairs (h, s) in which company h controls company s. There are at most 100 companies.

    Write a program to read the list of triples (i, j, p) where i, j and p are positive integers all in the range (1..100) and find all the pairs (h, s) so that company h controls company s.

    输入

    Multiple test cases. For each case:

    Line 1:    n, the number of input triples to follow

    Line 2..n+1:   Three integers per line as a triple (i, j, p) described above.

    输出

    Description

    Some companies are partial owners of other companies because they have acquired part of their total shares of stock. For example, Ford owns 12% of Mazda. It is said that a company A controls company B if at least one of the following conditions is satisfied:

    • Company A = Company B

    • Company A owns more than 50% of Company B

    • Company A controls K ( K ≥ 1 ) companies denoted C1, ..., CK with each company Ci owning xi% of company B and x1 + .... + xK > 50%.

    Given a list of triples (i, j, p) which denote company i owning p% of company j, calculate all the pairs (h, s) in which company h controls company s. There are at most 100 companies.

    Write a program to read the list of triples (i, j, p) where i, j and p are positive integers all in the range (1..100) and find all the pairs (h, s) so that company h controls company s.

    Input

    Multiple test cases. For each case:

    Line 1:    n, the number of input triples to follow

    Line 2..n+1:   Three integers per line as a triple (i, j, p) described above.

    Output

    For each case:

    List 0 or more companies that control other companies. Each line contains two integers that denote that the company whose number is the first integer controls the company whose number is the second integer. Order the lines in ascending order of the first integer (and ascending order of the second integer to break ties). Do not print that a company controls itself.

    Output a blank line after each case.

    Sample Input

    3
    1 2 80
    2 3 80
    3 1 20

    1
    30 80 100

    Sample Output

    1 2
    1 3
    2 3

    30 80

    Source

    样例输入

    3
    1 2 80
    2 3 80
    3 1 20

    1
    30 80 100

    样例输出

    1 2
    1 3
    2 3

    30 80

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部