21022_ExactChangeOnly

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

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

Pro.ID

21022

Title

Exact Change Only

Title链接

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

AC

0

Submit

699

Ratio

0.00%

时间&空间限制

  • Time Limit: 1500/500 MS (Java/Others)     Memory Limit: 131072/65536 K (Java/Others)
  • 描述

    Boudreaux reached over and shook awake Thibodeaux, who had dozed off somewhere in New Mexico. "Where we at?" Thibodeaux groggily yawned. 

    "Not in Vegas, I gua-ran-tee, but could you get my knapsack?" Boudreaux asked, gesturing to the worn, leather backpack in the back seat of their cherry red Ford Miata. 

    "Why, is there a problem?" 

    "Just hand me my knapsack, problem or not." 

    Thibodeaux complied, glancing up as Boudreaux slowed the car to a stop in a line of vehicles approaching a toll booth. "$1.65 -- Exact change only," Thibodeaux read the yellow sign on the front of a small wooden building occupied by a lone toll booth operator. "I have to get $1.65 in exact change?" Thibodeaux asked, digging through the knapsack, "all I have are ten quarters, four dimes, and three pennies. I don't have any nickels . . ." 

    "Just give me five of the quarters and the four dimes," Boudreaux replied, holding out his hand. 

    "Oh yeah," Thibodeaux said, handing over the coins, "that does add up to $1.65. I wish there were an easy way to figure out if you have an exact monetary amount, given a set of coins." 

    "Hmmm," Boudreaux shrugged, "sounds like a good programming problem."

    输入

    Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. 

    A single data set has 1 component: 

    Start line - A single line: 
    A B C D E 

    where: 
    A: (0.01 <= A <= 5.00) is a decimal number (to two decimal places) of a monetary amount. 
    B: (0 <= B <= 100) is an integer number of quarters (one quarter = $0.25). 
    C: (0 <= C <= 100) is an integer number of dimes (one dime = $0.10). 
    D: (0 <= D <= 100) is an integer number of nickels (one nickel = $0.05). 
    E: (0 <= E <= 100) is an integer number of pennies (one penny = $0.01).

    输出

    Description
    Boudreaux reached over and shook awake Thibodeaux, who had dozed off somewhere in New Mexico. "Where we at?" Thibodeaux groggily yawned. 

    "Not in Vegas, I gua-ran-tee, but could you get my knapsack?" Boudreaux asked, gesturing to the worn, leather backpack in the back seat of their cherry red Ford Miata. 

    "Why, is there a problem?" 

    "Just hand me my knapsack, problem or not." 

    Thibodeaux complied, glancing up as Boudreaux slowed the car to a stop in a line of vehicles approaching a toll booth. "$1.65 -- Exact change only," Thibodeaux read the yellow sign on the front of a small wooden building occupied by a lone toll booth operator. "I have to get $1.65 in exact change?" Thibodeaux asked, digging through the knapsack, "all I have are ten quarters, four dimes, and three pennies. I don't have any nickels . . ." 

    "Just give me five of the quarters and the four dimes," Boudreaux replied, holding out his hand. 

    "Oh yeah," Thibodeaux said, handing over the coins, "that does add up to $1.65. I wish there were an easy way to figure out if you have an exact monetary amount, given a set of coins." 

    "Hmmm," Boudreaux shrugged, "sounds like a good programming problem."
    Input
    Input to this problem will consist of a (non-empty) series of up to 100 data sets. Each data set will be formatted according to the following description, and there will be no blank lines separating data sets. 

    A single data set has 1 component: 

    Start line - A single line: 
    A B C D E 

    where: 
    A: (0.01 <= A <= 5.00) is a decimal number (to two decimal places) of a monetary amount. 
    B: (0 <= B <= 100) is an integer number of quarters (one quarter = $0.25). 
    C: (0 <= C <= 100) is an integer number of dimes (one dime = $0.10). 
    D: (0 <= D <= 100) is an integer number of nickels (one nickel = $0.05). 
    E: (0 <= E <= 100) is an integer number of pennies (one penny = $0.01).
    Output
    For each data set, there will be exactly one line of output. If there exists one or more subsets of the given coins whose values add up to the given monetary amount exactly, the output will be a single line in the form: 

    A B C D 

    where A is the number of quarters, B is the number of dimes, C is the number of nickels, and D is the number of pennies, for the subset with the fewest number of coins. Otherwise, the output will be a single line with the statement: 
    NO EXACT CHANGE
    Sample Input
    0.45 2 1 1 4
    0.75 3 7 1 75
    Sample Output
    NO EXACT CHANGE
    3 0 0 0
    Source

    样例输入

    0.45 2 1 1 4
    0.75 3 7 1 75

    样例输出

    NO EXACT CHANGE
    3 0 0 0

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部