1530_LEDModding

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

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

Pro.ID

1530

Title

LED Modding

Title链接

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

AC

8

Submit

9

Ratio

88.89%

时间&空间限制

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

    PC Modding has become the latest trendy hobby sweeping the nation. Since you don't have too much money to spare, and since modding is supposed to be a Do-It-Yourself sort of activity, you've decided to apply some simple modifications to your own PC.

    One quick modification you figured wouldn't cost too much is to add some Light Emitting Diodes (LEDs) to your case. Thus, you bought yourself some LEDs, and, once they arrived to your house, you started looking for power. In order to draw power from one of the standard connectors on your motherboard you would need a connector. Alas, you forgot to order any of those. You're left with your back-up plan: take the power from the USB adapter available on your motherboard using a USB cable, and plug in your bright blue LEDs. You have the USB cable ready to go, but you realize that you still have a problem to solve: the USB port on the motherboard does not always provide power at the same voltage required by the LEDs. Looking around, you find a convenient box of resistors that might just do the trick.

    Fortunately, you remember Ohm's Law:

    Voltage (in volts) = Current (in amperes) * Resistance (in ohms)

    and realize you can use resistance to lower the voltage provided by the USB adapter to that expected by the LEDs. You even remember that if you can't reduce the voltage to exactly what they expect, you can still get a nice glow if you reduce it to below the expected voltage. Of course, if you provide too much voltage, you'll get a very short bright display,  but you don't want to destroy your LEDs, so this is not acceptable.

    Likewise, if the voltage provided is 0 or lower, there will be no power to the LED, so this case is also unacceptable.

    输入

    The input file for this problem includes a series of 1 or more test cases.
    Each test case begins with a line formatted as follows:

    Where:
    is a positive integer value indicating how many volts the USB adapter on the motherboard produces;
    is a positive integer value indicating how many volts the LEDs expect to receive;
    is a positive integer value, in milliampere (each milliampere is a thousandth of an ampere) indicating the current at which the LEDs operate;
    is a non-negative integer number indicating how many types of resistors are available in the test case.

    This line is followed by lines each describing a type of resistor available. All types of resistors available in a given test case are different from each other. This means that their names and resistance values are all different. These lines are formatted as follows:

    Where is a sequence of at most 40 alphabetic characters, and
    is a positive integer, giving the resistance of that type of resistors,
    measured in ohms.

    The end of input will be indicated by end of file.

    输出

    Description

    PC Modding has become the latest trendy hobby sweeping the nation. Since you don't have too much money to spare, and since modding is supposed to be a Do-It-Yourself sort of activity, you've decided to apply some simple modifications to your own PC.

    One quick modification you figured wouldn't cost too much is to add some Light Emitting Diodes (LEDs) to your case. Thus, you bought yourself some LEDs, and, once they arrived to your house, you started looking for power. In order to draw power from one of the standard connectors on your motherboard you would need a connector. Alas, you forgot to order any of those. You're left with your back-up plan: take the power from the USB adapter available on your motherboard using a USB cable, and plug in your bright blue LEDs. You have the USB cable ready to go, but you realize that you still have a problem to solve: the USB port on the motherboard does not always provide power at the same voltage required by the LEDs. Looking around, you find a convenient box of resistors that might just do the trick.

    Fortunately, you remember Ohm's Law:

    Voltage (in volts) = Current (in amperes) * Resistance (in ohms)

    and realize you can use resistance to lower the voltage provided by the USB adapter to that expected by the LEDs. You even remember that if you can't reduce the voltage to exactly what they expect, you can still get a nice glow if you reduce it to below the expected voltage. Of course, if you provide too much voltage, you'll get a very short bright display,  but you don't want to destroy your LEDs, so this is not acceptable.

    Likewise, if the voltage provided is 0 or lower, there will be no power to the LED, so this case is also unacceptable.

    Input

    The input file for this problem includes a series of 1 or more test cases.
    Each test case begins with a line formatted as follows:

    Where:
    is a positive integer value indicating how many volts the USB adapter on the motherboard produces;
    is a positive integer value indicating how many volts the LEDs expect to receive;
    is a positive integer value, in milliampere (each milliampere is a thousandth of an ampere) indicating the current at which the LEDs operate;
    is a non-negative integer number indicating how many types of resistors are available in the test case.

    This line is followed by lines each describing a type of resistor available. All types of resistors available in a given test case are different from each other. This means that their names and resistance values are all different. These lines are formatted as follows:

    Where is a sequence of at most 40 alphabetic characters, and
    is a positive integer, giving the resistance of that type of resistors,
    measured in ohms.

    The end of input will be indicated by end of file.

    Output
    For each test case in the input file you should produce a single line in the output file formatted as follows:

    Where is the optimum resistance in ohms that should be added to the circuit to make the LEDs receive the power they expect, and is the name of the resistor, out of those available in the test case, that should be used. In displaying the optimal resistance, use 2 decimal digits, rounding any additional digits.
    When no resistor available provides the optimal resistance for the test case, you should select the resistor that is the closest to the optimum resistance and still makes the circuit work (providing to the LEDs less current than they expect).
    If the circuit cannot be made to work with the given parts, instead of a line formatted as described above, your output file should include a line with only the "IMPOSSIBLE" string in it.
    If the USB port provides acceptable voltage without addition to resistance to the LED, the output line should only include the "---" string.
    Sample Input
    5 3 20 2
    Red 90
    Orange 110
    5 3 20 2
    ThisOne 110
    TheOtherOne 100
    5 3 20 1
    TooLittle 90
    5 5 20 1
    Sample 10
    Sample Output
    100.00 Orange
    100.00 TheOtherOne
    IMPOSSIBLE
    ---
    Author

    样例输入

    5 3 20 2
    Red 90
    Orange 110
    5 3 20 2
    ThisOne 110
    TheOtherOne 100
    5 3 20 1
    TooLittle 90
    5 5 20 1
    Sample 10

    样例输出

    100.00 Orange
    100.00 TheOtherOne
    IMPOSSIBLE
    ---

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部