Make them equal codechef solution in c++

#include <iostream>
using namespace std;

int main() {
    int T;
    cin >> T; // Input the number of test cases

    while (T--) {
        int X, Y, K;
        cin >> X >> Y >> K; // Input values for X, Y, and K

        int sticks_needed = ((Y * K) + K - 1) / (X - 1); // Calculate the sticks needed

        if (((Y * K) + K - 1) % (X - 1) != 0) {
            sticks_needed++; // Increment sticks_needed if there are remaining sticks
        }

        cout << sticks_needed + K << endl; // Output the total sticks required
    }

    return 0;
}

Explanation:

  1. #include <iostream>: Includes the Input/Output stream.
  2. using namespace std;: Allows usage of functions and objects in the standard C++ library without prepending std::.
  3. int main() { ... }: Entry point of the program.
  4. int T; cin >> T;: Reads the number of test cases.
  5. while (T--) { ... }: Executes a loop for each test case.
  6. int X, Y, K; cin >> X >> Y >> K;: Inputs the values of X, Y, and K.
  7. int sticks_needed = ((Y * K) + K - 1) / (X - 1);: Calculates the minimum number of sticks needed.
  8. if (((Y * K) + K - 1) % (X - 1) != 0) { sticks_needed++; }: Adjusts sticks_needed if there are remaining sticks.
  9. cout << sticks_needed + K << endl;: Outputs the total sticks required for the current test case.
  10. return 0;: Indicates successful completion of the program execution.