Advertisement
fueanta

codeabbey #22

Mar 23rd, 2017
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.73 KB | None | 0 0
  1. // two printers
  2. // input time required to print a page for each printer & total pages (X, Y, N)
  3. // minimum required time to finish off
  4.  
  5. #include <iostream>
  6. using namespace std;
  7.  
  8. int eachCase();
  9.  
  10. int main() {
  11.     int totalCases;
  12.     cin >> totalCases;
  13.  
  14.     int* answers = new int[totalCases];
  15.     for (int i = 0; i < totalCases; i++) {
  16.         answers[i] = eachCase();
  17.     }
  18.     for (int i = 0; i < totalCases; i++) {
  19.         cout << answers[i] << " ";
  20.     }
  21.  
  22.     cout << endl;
  23.     return 0;
  24. }
  25.  
  26. int eachCase() {
  27.     int x, y, n;
  28.     cin >> x >> y >> n;
  29.    
  30.     int printed = 0, countedTime = 0;
  31.     while (printed != n) {
  32.         countedTime++;
  33.         if (countedTime % x == 0) printed++;
  34.         if (printed == n) break;
  35.         if (countedTime % y == 0) printed++;
  36.     }
  37.     return countedTime;
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement