Richie Rich Codechef Solution

Hello Programmers In this post, you will know how to solve the Richie Rich Codechef Solution.

Richie Rich Codechef Solution
Richie Rich Codechef Solution

One more thing to add, don’t directly look for the solutions, first try to solve the problems of Codechef by yourself. If you find any difficulty after trying several times, then you can look for solutions.


Chef aims to be the richest person in Chefland by his new restaurant franchise. Currently, his assets are worth AA billion dollars and have no liabilities. He aims to increase his assets by XX billion dollars per year.

Also, all the richest people in Chefland are not planning to grow and maintain their current worth.

To be the richest person in Chefland, he needs to be worth at least BB billion dollars. How many years will it take Chef to reach his goal if his value increases by XX billion dollars each year?


  • The first line contains an integer TT, the number of test cases. Then the test cases follow.
  • Each test case contains a single line of input, three integers AA, BB, XX.


For each test case, output in a single line the answer to the problem.


  • 1≤T≤21 0001≤T≤21 000
  • 100≤A<B≤200100≤A<B≤200
  • 1≤X≤501≤X≤50
  • XX divides B−AB−A


Subtask #1 (100 points): Original constraints

Sample Input

100 200 10
111 199 11
190 200 10

Sample Output



Test Case 11: Chef needs to increase his worth by 200−100=100200−100=100 billion dollars and his increment per year being 1010 billion dollars, so it will take him 10010=1010010=10 years to do so.

Test Case 22: Chef needs to increase his worth by 199−111=88199−111=88 billion dollars and his increment per year being 1111 billion dollars, so it will take him 8811=88811=8 years to do so.

Test Case 33: Chef needs to increase his worth by 200−190=10200−190=10 billion dollars and his increment per year being 1010 billion dollars, so it will take him 1010=11010=1 year to do so.

Richie Rich CodeChef Solutions in JAVA

import java.util.*;
public class Main
	public static void main(String[] args) throws IOException
			Scanner sc = new Scanner(;
			int t = sc.nextInt();
			for(int i=0;i<t;i++){
			    int A = sc.nextInt();
			    int B = sc.nextInt();
			    int X = sc.nextInt();
			    int need_to_increase = B - A;
			    int years = need_to_increase / X;
		}catch(Exception e){

Richie Rich CodeChef Solutions in CPP

using namespace std;
int main()
    int t;
    for(int i=0;i<t;i++)
        int a,b,x;
        int z=(b-a)/x;
    return 0;

Richie Rich CodeChef Solution in Python

for i in range(t):

Disclaimer: The above Problem (Richie Rich) is generated by CodeChef but the solution is provided by BrokenProgrammers. This tutorial is only for Educational and Learning purpose.

Note:- I compile all programs, if there is any case program is not working and showing an error please let me know in the comment section. If you are using adblocker, please disable adblocker because some functions of the site may not work correctly.

Next: Chef and Demonetisation Codechef Solution

Leave a Reply

Your email address will not be published. Required fields are marked *