Company: Consultadd_8june
Difficulty: medium
A factory manufactures smart gadgets. Each gadget requires a recipe string consisting of components: A B C For example: AABC means: 2 units of component A 1 unit of component B 1 unit of component C The factory currently has: some existing inventory, market prices for each component, new components can be purchased to manufacture more gadgets, and a limited budget. Determine the maximum number of gadgets the factory can manufacture. Input Format Recipe string Three integers representing available inventory of A B C Three integers representing price of A B C Integer budget Output Format Print a single integer – maximum gadgets producible. Constraints All values fit within 64-bit signed integers. Efficient logarithmic optimization is expected. NOTE Components can be bought in unlimited quantity. Sample Input 1 ABC 1 1 1 1 1 3 1000000000000 Sample Output 1 200000000001 Test Case 1 Input ABB 1 2 1 3 4 5 17 Output 2 Test Case 2 Input AAABBC 6 4 1 1 2 3 4 Output 2