-->
当前位置:首页 > 题库

PROGRAMMING:Buying in bulk

Luz5年前 (2021-05-10)题库400
18 computer Niu Jianyue 21:54:51
To encourage customers to shop more, some stores charge lower prices if you buy multiple of an item. For example, if you buy one, it may cost you 5 but if you buy two, it will cost you 5 but if you buy two, it will cost you 8 instead of $10, Some stores will sell it at a lower price. For example, if you buy one, it may cost you $5, but if you buy two, it will cost you $5, but if you buy two, it won't be $10.)
The Problem:
Let’s assume a store provides discounts as follows:1. No discount if you buy only one.2. $2 discount for each additional item if you buy more than one.Given the number of items a customer has purchased and the price for one item, Let's assume that a store offers the following discount: you are to calculate the total cost for the customer. If you buy one more piece, you can get a discount of 2 yuan. Given the quantity of goods purchased by a customer and the price of the goods, you will calculate the total cost of that customer.)
18 computer Niu Jianyue 21:55:02
###Input format:
The first input line contains a positive integer, n, indicating the number of customers to check. The customers are on the following n input lines, one customer per line. Each line provides two integers; The first integer C (1 ≤ C ≤ 100) is the number of items purchased by the customer, and the second integer P (3 ≤ P ≤ 50) is the price for one item. Customers are on the following N input lines, one customer per line. Two integers are provided for each line; The first integer C (1 ≤ C ≤ 100) is the quantity of goods purchased by customers, and the second integer P (3 ≤ P ≤ 50) is the price of a commodity.)
###Output format:
For each customer, print two lines of output. The first line will contain the two input values separated by a single space. The second output line will contain the total cost for the customer. There should be no leading or training spaces on any output line. The first line contains two input values separated by a space. The second output line contains the total cost of the customer. There should be no leading or trailing spaces on any output line.)
###Input example:
Here is a set of inputs. For example:
```in
two
1 5
3 10
```
###Output example:
The corresponding output is given here. For example:
```out
1 5
five
3 10
twenty-six
```







answer:If there is no answer, please comment