Published September 10, 2022 by

Bob at the Bank Java Solution (BOBBANK)

Problem

  • Bob has an account in the Bobby Bank. His current account balance is W rupees.
  • Each month, the office in which Bob works deposits a fixed amount of X rupees to his account.
  • Y rupees is deducted from Bob's account each month as bank charges.
  • Find his final account balance after Z months. Note that the account balance can be negative as well.

Input Format

  • The first line will contain TT, the number of test cases. Then the test cases follow.
  • Each test case consists of a single line of input, containing four integers W,X,Y, and Z — the initial amount, the amount deposited per month, the amount deducted per month, and the number of months.

Output Format

  • For each test case, output in a single line the final balance in Bob's account after Z months.

Constraints

  • 1 \leq T \leq 1000
  • 1 \leq W,X,Y,Z \leq 10^4

Input

  • 3 100 11 1 10 999 25 36 9 2500 100 125 101

Output
  • 200 900 -25

Explanation:

Test case 1: Bob's current account balance is 100. At the end of each month Bob gets Rs 11 and pays Rs 1, thus gaining 10 per month. Thus, at the end of 10 months, Bob will have 100 + 10 \times 10 = 200.

Test case 2: Bob's current account balance is 999. At the end of each month Bob gets Rs 25 and pays Rs 36, thus losing 11 per month. Thus, at the end of 9 months, Bob will have 999 - 11 \times 9 = 900.

Test case 3: Bob's current account balance is 2500. At the end of each month Bob gets Rs 100 and pays Rs 125, thus losing 25 per month. Thus, at the end of 101 months, Bob will have 2500 - 25 \times 101 = -25.


Read More
Published September 10, 2022 by

Chef and Wire Frames Java Solution (CWIREFRAME)

Problem

  • Chef has a rectangular plate of length N cm and width M cm. He wants to make a wireframe around the plate. The wireframe costs X rupees per cm.

  • Determine the cost Chef needs to incur to buy the wireframe.

Input Format

  • First line will contain TT, the number of test cases. Then the test cases follow.

Each test case consists of a single line of input, containing three space-separated integers N,M,N,M, and XX — the length of the plate, width of the plate, and the cost of frame per cm.

Output Format

For each test case, output in a single line, the price Chef needs to pay for the wireframe.

Constraints

  • 1 \leq N,M,X \leq 1000

Explanation:

Test case 1: The total length of the frame is 2\cdot 10 + 2\cdot 10 = 40 cms. Since the cost is 10 per cm, the total cost would be 10 \cdot 40 = 400.

Test case 2: The total length of the frame is 2\cdot 23 + 2\cdot 3 = 52 cms. Since the cost is 12 per cm, the total cost would be 52 \cdot 12 = 624.

Test case 3: The total length of the frame is 2\cdot 1000 + 2\cdot 1000 = 4000 cms. Since the cost is 1000 per cm, the total cost would be 4000 \cdot 1000 = 4000000.

INPUT

3 10 10 10 23 3 12 1000 1000 1000

OUTPUT

400 624 4000000

Read More
Published September 07, 2022 by

Balls and Boxes Codechef Solution Java (BALLBOX)

Problem

  • You have NN balls and KK boxes. You want to divide the NN balls into KK boxes such that:
  • Each box contains  ≥1 balls.
  • No two boxes contain the same number of balls.
  • Determine if it is possible to do so.


Input Format

  • The first line contains a single integer TT — the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains two space-separated integers NN and KK — the number of balls and the number of boxes respectively.

Output Format

  • For each test case, output YES if it is possible to divide the NN balls into KK boxes such that the conditions are satisfied. Otherwise, output NO.
  • You may print each character of YES and NO in uppercase or lowercase (for example, yes, yEs, Yes will be considered identical).

Constraints

  • 1 \le N \le 10^9
  • 1 \le K \le 10^4

Read More
Published September 07, 2022 by

Broken Phone Codechef Solution Java: (BROKENPHONE)

Problem

  • Uttu broke his phone. He can get it repaired by spending XX rupees or he can buy a new phone by spending YY rupees. Uttu wants to spend as little money as possible. Find out if it is better to get the phone repaired or to buy a new phone.

Input Format

  • The first line contains a single integer TT — the number of test cases. Then the test cases follow.
  • The first and only line of each test case contains two space-separated integers XX and YY — the cost of getting the phone repaired and the cost of buying a new phone.

Output Format

For each test case,

  • output REPAIR if it is better to get the phone repaired.
  • output NEW PHONE if it is better to buy a new phone.
  • output ANY if both the options have the same price.

You may print each character of REPAIR, NEW PHONE and ANY in uppercase or lowercase (for example, any, ANy, Any will be considered identical).

Constraints

  • 1<=T<=1000
  • 1<=X,Y<=10000
Read More