WBILL - Water Bill Company
Recently, clean water has became scarce and expensive. Louis water company, the one and only water company in your country, has raised the rates for water supply. The table below shows the new rates (consumption is always a positive integer):
This means that, when calculating the amount to pay, the first 100 liters have a price of 2 Rapiuhs each; the next 900 liters (between 101 and 1000) have a price of 3 Rapiuhs each and so on. For instance, if you consume 10987 liters you will have to pay 2*100 + 3*900 + 5*9000 + 7*987= 54809 Rapiuhs.
Many people were unhappy with the new rates. After that, Malfple, the infamous hacker in your country, hacked the company server and modified the billing system. Instead of showing the bill of each customers, the billing system now shows the price for the sum of the usage of every 2 customers and the absolute difference between the billing of the 2 customers. As a noted programmer there, the company asks you to help them to create a program to determine the amount billing of each costumer, given the value from the hacked billing system.
InputInput starts with an integer T (1 ≤ T ≤ 1000), denoting the number of test cases. Each of the test case consists of integer N and M (0 ≤ M ≤ N ≤ 2*10^9), denoting the the price for the sum of the usage of every 2 customers and the absolute difference of billing between two customers. You can assume there is always a unique solution, that is, there exists exactly one pair of consumption that produces those numbers.
OutputFor each case, print "Case #X: A B", where X (1 ≤ X ≤ T) is the case number, A and B are the amount of the 2 customers have to pay in increasing order. There must be no trailing spaces at the end of printed lines, neither empty characters. Print a newline after each testcase.
Input: 3 200 100 2240 1955 21350 20466 Output: Case #1: 50 150 Case #2: 114 2069 Case #3: 269 20735
Harder than I expected. Could be a classical unless there is a simple solution that evaded me.
When a problem created by a high schooler is used as a task for undergraduates...