# Hungry Chef CodeChef Solution

### We Are Discuss About CODECHEF SOLUTION

Hungry Chef CodeChef Solution

## Hungry Chef CodeChef Solution

Alice likes all the numbers which are divisible by A. Bob does not like the numbers which are divisible by B and likes all the remaining numbers. Determine the smallest number greater than or equal to N which is liked by both Alice and Bob. Output -1 if no such number exists.

### Input Format

• The first line contains a single integer T — the number of test cases. Then the test cases follow.
• The first and only line of each test case contains three space-separated integers AB and N — the parameters mentioned in the problem statment.

### Output Format

For each test case, output the smallest number \ge N which is divisible by A and is not divisible by B. Output -1 if no such number exists.

## Hungry Chef CodeChef Solution

Chef is very hungry. So, Chef goes to a shop selling burgers. The shop has 2 types of burgers:

• Normal burgers, which cost X rupees each
• Premium burgers, which cost Y rupees each (where Y \gt X)

Chef has R rupees. Chef wants to buy exactly N burgers. He also wants to maximize the number of premium burgers he buys. Determine the number of burgers of both types Chef must buy.

Output -1 if it is not possible for Chef to buy N burgers.

### Input Format

• The first line contains a single integer T — the number of test cases. Then the test cases follow.
• The first and only line of each test case contains four space-separated integers XYN and R — the cost of a normal burger, the cost of a premium burger, the number of burgers Chef wants to buy and the amount of money Chef has.

### Output Format

For each test case, output on a new line two integers: the number of normal burgers and the number of premium burgers Chef must buy satisfying the given conditions.

Output -1 if he cannot buy N burgers.

## Hungry Chef CodeChef Solution

### Constraints

• 1 \leq T \leq 10^4
• 1 \le X \lt Y \le 1000
• 1 \le N \le 10^6
• 1 \le R \le 10^9

### Sample 1:

Input

Output

4
2 10 4 12
4 8 10 50
99 100 5 10
9 10 10 200

4 0
8 2
-1
0 10


### Explanation:

Test case 1: Chef has to buy 4 normal burgers only. Even if he buys 1 premium burger, he would not be able to buy 4 burgers.

Test case 2: Chef can buy 8 normal burgers and 2 premium burgers.

Test case 3: It is not possible for Chef to buy 5 burgers.

## SOLUTION

Yhaa You have done it but next? if YOU Want to Get Others Please Visit Here ScishowEngineer   Then Follow US HERE and Join Telegram.

If You Want To Learn Something New Then Visit Our Official Channel YOUTUBE