ZOJ Problem Set - 3564
The capital stock (or just stock) of a business entity represents the original capital paid into or invested in the business by its founders. It serves as a security for the creditors of a business since it cannot be withdrawn to the detriment of the creditors. Stock is distinct from the property and the assets of a business which may fluctuate in quantity and value.
The only key to be success in the stock is buying at a low price and selling at a high price. There are a lot of technical terms. But in this problem, you should only know something following.
SXSTAR has bought a stock with N shares at P price each stock. Because of the Dividend Issue and Scrip Issue, the price has changed a lot. He wants to know the lowest price to sell them out at which he will not lose money.
There are several test cases (<=200). You should process to the end of input. For each test case, there are two parts. The first part has two lines. The first line has two integers N (0 <= N <= 1000000) and Ticker Symbol (indicates the code of stock SXSTAR has bought). The second line has one real number P (0 < P <= 100000). The first line of the second part has only one integer M (0 <= M <= 200). Then followed by M lines. Each line has a character CH (CH='D' means Dividend Issue; CH='S' means Scrip Issue) and a real number C (0 <= C <= 100000, indicates the corresponding coefficient). All these operations are listed in time order.
For each case, you should print a single line with the number of the lowest price to sell them out at which he will not lose money after all the operation given. Your answer should include two decimal places as the definition of Unit Price. Data ensure that the final answer is positive.
10000 000001 11 0 10000 000002 22 1 S 10
Author: SHEN, Xin
Contest: ZOJ Monthly, December 2011