- محدودیت زمان: ۱ ثانیه
- محدودیت حافظه: ۲۵۶ مگابایت
Nowadays everything depends on exchange rate of dollar (Now it is called rate due to its importance). Total atmosphere of our country has been affected by rate. But this is not the only reason of economical disorders. Some of sellers called "traitors" cause the other reason. These sellers act different in different rate swings:
- In rate increment, they increase the price of goods bought before and pretext: "I must increase because I need to buy this good again".
- In rate decrement, they don't decrease the price of goods bought before and pretext: "I paid more and decrement has lots of damages for me”.
Actually if rate changes from to (and ), traitors multiply their price to and round the product to the nearest(if distances were equal, to upper nearest) multiple of round base. For example if a traitor bought a pen in first day and rate changed from to and then to , and round base was , finally he sells this pen . because: and is closer to .
Ali wants to buy a battery for his laptop. But there is only one shop selling this kind of battery. Ali knows that this shop's seller is a traitor and has this battery since n days ago. Ali went to this shop and realised that the seller sells the battery p Rials and round base for this shop is b Rials. Ali wants to know how much was this battery's price d days ago. He is busy preparing problems for SBU Newbies Contest so he needs your help.
ورودی
The input file contains several input sets. The description of each set is given below:
Each set starts with four integers , the number of days passed from seller's buy, , the price of battery, , round base, and , the number of days passed from Ali's slightly day, following a line with non-negative space separated integers . equals the rate when days passed from seller's buy. Actually equals the rate when seller bought the battery. It is guaranteed that Input will follow the descriptions given.Input is terminated by a set where which should not be processed. There is a blank line between two input sets. sum of over all input sets are at most and count of input sets are less than .
خروجی
For each input set, produce one line of output including space separated and which respectively mean the least and the most possible prices the battery could have in d days ago.
مثالها
ورودی نمونه ۱
خروجی نمونه ۱
ارسال پاسخ برای این سؤال