10161_FeedRatios

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

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

Pro.ID

10161

Title

Feed Ratios

Title链接

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

AC

17

Submit

40

Ratio

42.50%

时间&空间限制

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

    Farmer John feeds his cows only the finest mixture of cow food, which has three components: Barley, Oats, and Wheat. While he knows the precise mixture of these easily mixable grains, he can not buy that mixture! He buys three other mixtures of the three grains and then combines them to form the perfect mixture.

    Given a set of integer ratios barley:oats:wheat, find a way to combine them IN INTEGER MULTIPLES to form a mix with some goal ratio x:y:z.

    For example, given the goal 3:4:5 and the ratios of three mixtures:

    1:2:3
    3:7:1
    2:1:2

    your program should find some minimum number of integer units (the 'mixture') of the first, second, and third mixture that should be mixed together to achieve the goal ratio or print 'NONE'. 'Minimum number' means the sum of the three non-negative mixture integers is minimized.

    For this example, you can combine eight units of mixture 1, one unit of mixture 2, and five units of mixture 3 to get seven units of the goal ratio:

    8×(1:2:3) + 1×(3:7:1) + 5×(2:1:2) = (21:28:35) = 7×(3:4:5)

    Integers in the goal ratio and mixture ratios are all non-negative and smaller than 100 in magnitude. The number of units of each type of feed in the mixture must be less than 100. The mixture ratios are not linear combinations of each other.

    输入

    Multiple test cases. For each case:

    Line 1:    Three space separated integers that represent the goal ratios

    Line 2..4:    Each contain three space separated integers that represent the ratios of the three mixtures purchased.

    输出

    Description

    Farmer John feeds his cows only the finest mixture of cow food, which has three components: Barley, Oats, and Wheat. While he knows the precise mixture of these easily mixable grains, he can not buy that mixture! He buys three other mixtures of the three grains and then combines them to form the perfect mixture.

    Given a set of integer ratios barley:oats:wheat, find a way to combine them IN INTEGER MULTIPLES to form a mix with some goal ratio x:y:z.

    For example, given the goal 3:4:5 and the ratios of three mixtures:

    1:2:3
    3:7:1
    2:1:2

    your program should find some minimum number of integer units (the 'mixture') of the first, second, and third mixture that should be mixed together to achieve the goal ratio or print 'NONE'. 'Minimum number' means the sum of the three non-negative mixture integers is minimized.

    For this example, you can combine eight units of mixture 1, one unit of mixture 2, and five units of mixture 3 to get seven units of the goal ratio:

    8×(1:2:3) + 1×(3:7:1) + 5×(2:1:2) = (21:28:35) = 7×(3:4:5)

    Integers in the goal ratio and mixture ratios are all non-negative and smaller than 100 in magnitude. The number of units of each type of feed in the mixture must be less than 100. The mixture ratios are not linear combinations of each other.

    Input

    Multiple test cases. For each case:

    Line 1:    Three space separated integers that represent the goal ratios

    Line 2..4:    Each contain three space separated integers that represent the ratios of the three mixtures purchased.

    Output

    For each case,  output one line containing four integers or the word 'NONE'. The first three integers should represent the number of units of each mixture to use to obtain the goal ratio. The fourth number should be the multiple of the goal ratio obtained by mixing the initial feed using the first three integers as mixing ratios.

    Sample Input

    3 4 5
    1 2 3
    3 7 1
    2 1 2

    Sample Output

    8 1 5 7

    Source

    样例输入

    3 4 5
    1 2 3
    3 7 1
    2 1 2

    样例输出

    8 1 5 7

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部