Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // two printers
- // input time required to print a page for each printer & total pages (X, Y, N)
- // minimum required time to finish off
- #include <iostream>
- using namespace std;
- int eachCase();
- int main() {
- int totalCases;
- cin >> totalCases;
- int* answers = new int[totalCases];
- for (int i = 0; i < totalCases; i++) {
- answers[i] = eachCase();
- }
- for (int i = 0; i < totalCases; i++) {
- cout << answers[i] << " ";
- }
- cout << endl;
- return 0;
- }
- int eachCase() {
- int x, y, n;
- cin >> x >> y >> n;
- int printed = 0, countedTime = 0;
- while (printed != n) {
- countedTime++;
- if (countedTime % x == 0) printed++;
- if (printed == n) break;
- if (countedTime % y == 0) printed++;
- }
- return countedTime;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement