a058: Music CD Boxes 音樂CD盒
標籤 : 流程控制,迴圈
通過比率 : 67% (2 人 / 3 人 ) (非即時)
評分方式 :
Tolerant

最近更新 : 2019-04-09 08:58

內容

Ming is a person who likes to listen to music, so he has lots of music CDs, and now he wants to buy a CD box to store CDs. There are only two kinds of CD boxes on the market, one can hold n1 pieces and sell for d1 dollars, and the other can hold n2 pieces and sell for d2 dollars. The CD box that Ming hopes to buy is full in use, and he hopes to buy it with the least amount of money. Now, please write a program to decide how many these two boxes Ming should buy.

小明是個喜歡聽音樂的人,所以他擁有很多音樂 CD ,現在他想要買CD 盒來裝 CD 。市面上只有兩種 CD 盒,一種可以裝  n  片並且售價 d1 元,另一種可以裝  n  片並且售價 d2  元。小明希望買到的 CD 盒在使用上都是裝滿的,而且希望花最少的錢來買。現在請你幫小明寫一個程式來決定小明該買這兩種盒子各多少個才好。

輸入說明

The first row is a positive integer n (0 < n < 10), which means there are n testing data. The format of each testing data is as follows:

There are a total of three rows of data entered. The first row is to enter a positive integer N (the number of Ming’s CDs), the second row is to input positive integers n1, d1, and the third column is to input positive integers n2, d2, (1 ≤ N, n1, d1, n2, d2, ≤ 1000000).

 

第一列為一正整數 n (0 < n < 10),代表有 n筆測資;每筆測資的格式如下:

輸入總共有三列資料。第一列是輸入一個正整數 N (小明的CD數),第二列是輸入正整數 n1、d1  ,第三列是輸入正整數 n2、d2   ,(1 ≤ N、n1、d1 n2、d2  ≤ 1000000) 。

輸出說明

The output is a list of data, including two integers greater than or equal to zero, respectively representing the number of boxes purchased. If no solution is found to satisfy the problem, output "false". A newline character should be added at the end of the output.

 

輸出為一列資料,包含兩個大於等於零的整數分別代表兩種盒子買的數量,如果找不到滿足題意的解,就輸出 ”false”。最後必須有換行字元。

範例輸入
2
50
1 2
3 4
48
4 9
3 6
範例輸出
2 16
0 16
測資資訊 :
記憶體限制 : 64 MB
隱藏 測資點#0 (50%): 1.0s , <1K
隱藏 測資點#1 (50%): 1.0s , <1K
提示 :
標籤:
流程控制,迴圈
出處:
ITSA_56th [編輯 :
shengZJ (shengZJ)
]


編號 身分 題目 主題 人氣 發表日期
沒有發現任何「解題報告」