Advertisement
Spocoman

Number Generator

Sep 25th, 2023
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main() {
  6.     int m, n, l, special, control;
  7.     cin >> m >> n >> l >> special >> control;
  8.  
  9.     for (int i = m; i > 0; i--) {
  10.         for (int j = n; j > 0; j--) {
  11.             for (int k = l; k > 0; k--) {
  12.                 int num = i * 100 + j * 10 + k;
  13.  
  14.                 if (num % 3 == 0) {
  15.                     special += 5;
  16.                 }
  17.                 else if (num % 5 == 0) {
  18.                     special -= 2;
  19.                 }
  20.                 else if (num % 2 == 0) {
  21.                     special *= 2;
  22.                 }
  23.  
  24.                 if (special >= control) {
  25.                     cout << "Yes! Control number was reached! Current special number is " << special << ".\n";
  26.                     return 0;
  27.                 }
  28.             }
  29.         }
  30.     }
  31.     cout << "No! " << special << " is the last reached special number.\n";
  32.     return 0;
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement