NIKOLAY_TETUS

Untitled

Jun 17th, 2021 (edited)
371
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. bool func(long long x)
  8. {
  9.     long long minDif = 9999999999;
  10.     long long maxDif = -9999999999;
  11.  
  12.     long long pairsAmount = 0;
  13.  
  14.     long long difNow = 0;
  15.  
  16.     for (long long i = 1; i < x; i++)
  17.         for (long long j = 1; j < x; j++)
  18.         {
  19.             if (i * j != x)
  20.                 continue;
  21.  
  22.             //Получаем текущую разность сомножителей
  23.             difNow = abs(i - j);
  24.  
  25.             if (difNow < minDif)
  26.                 minDif = difNow;
  27.  
  28.             if (difNow > maxDif)
  29.                 maxDif = difNow;
  30.  
  31.             pairsAmount++;
  32.         }
  33.  
  34.     if (minDif > 4444 && (maxDif % minDif == 0 && minDif > 0) && pairsAmount >= 2)
  35.     {
  36.         cout << x << minDif << endl;
  37.         return true;
  38.     }
  39.  
  40.     return false;
  41. }
  42.  
  43. int main()
  44. {
  45.     for (int i = 543210; i < 987655; i++)
  46.     {
  47.         cout << i << ")";
  48.         func(i);
  49.     }
  50.  
  51.     return 0;
  52. }
  53.  
Add Comment
Please, Sign In to add comment