Submit | All submissions | Best solutions | Back to list |
UCV2013C - Farmer Cream |
Farmer Cream is a businessman that wants to live in the suburbs. He recently bought a little farm in Creamville and wants to earn money from it. After the purchase, Farmer Cream has D money remaining to spend. He's in negotiations with an important firm of farming but he thinks they're not being honest (they're trying to steal some money). He knows the number of fences F in the farm but he doesn't know the number of plots P to farm. The firm is offering a budget B per plot, so he needs to multiply the budget per the number of plots to know the total amount of money to spend. He needs to know if he accepts the contract, for that, he needs to have at least M money to live after the buy. Otherwise, the firm is trying to bankrupt Farmer Cream and take over the farm.
In order to do this. Farmer Cream needs your help. Assuming the fences are lines y = ax + b he only knows three things about them.
- There is no point in the farm where 3 or more fences collides. So, in one point of the farm there'll be zero, one or two fences.
- There are no parallel fences in the farm. So if we have two fences represented by y1 = a1x1 + b1 and y2 = a2x2 + b2 we assume that a1 <> a2.
- All the fences collide with each other
In the example, there are 3 fences and 7 plots.
Input
The input contains several test cases, each one corresponding to a different situation. Each test case consists of a single line with four integers D F B M (1 <= F,B,M <= 10^6) and (1 <= D <= 10^18) separated by a single space. D represents the remaining money of Farmer Cream, F represents the number of fences, B represents the budget in Bsf per plot and M represents the minimum amount of money that Farmer Cream needs to live.
The end of input is indicated by a test case with D = F = B = M = 0.
Output
For each test case, you'll print: "The firm is trying to bankrupt Farmer Cream by X Bsf." where X represents the difference between money to spend plus the money he needs to survive and the money Farmer Cream has. Otherwise, you'll print "Farmer Cream will have Y Bsf to spend." where Y represents the money Farmer Cream will have to spend.
Example
Input: 160 1 70 30
500 3 50 100
250000 40 300 5000
0 0 0 0 Output: The firm is trying to bankrupt Farmer Cream by 10 Bsf.
Farmer Cream will have 150 Bsf to spend.
The firm is trying to bankrupt Farmer Cream by 1300 Bsf.
Added by: | Hector Navarro |
Date: | 2013-07-22 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Local UCV 2013. Fernando Crema |
hide comments
|
||||||
2013-10-29 11:54:15 Rohit Retnakaran
got 5 WA just because of writing Bsf as Bsd :P |
||||||
2013-09-17 17:48:30 Syntax Terror
OEIS.. :D |
||||||
2013-08-12 20:21:57 tamed
AC :) Last edit: 2013-08-13 19:49:56 |
||||||
2013-08-12 16:23:16 K
AC in 1st attempt.. :) |
||||||
2013-07-30 19:11:12 shiva_hellgeek
This problem brings up my 250!! :D |
||||||
2013-07-29 17:58:00 mystique_blue
Dont use unsigned long long use signed long long check for the stupid case 1 1 1 1 ans is <10. |
||||||
2013-07-28 11:03:33 game2712
why giving WA dont Understand plz help Last edit: 2013-07-28 11:03:52 |
||||||
2013-07-26 15:29:51 Chandan Mittal
Last edit: 2013-07-26 15:31:27 |
||||||
2013-07-26 09:43:00 Joey Tribbiani
What is the result for 1000000000000000000 1000000 1000000 1000000 0 0 0 0 |