Advertisement
daniilpro

Untitled

Oct 28th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.76 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <algorithm>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. double a[5];
  9. double A, B, C, D, E;
  10.  
  11. int main()
  12. {
  13.     ios::sync_with_stdio(false);
  14.    
  15.     cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
  16.    
  17.     sort(begin(a),end(a));
  18.     int min = 0;
  19.     for (int i = 0;i<5;++i)
  20.     {
  21.         if (a[i] != 0) { min = a[i];break; }
  22.     }
  23.  
  24.     int num = 0;
  25.  
  26.     while (true)
  27.     {
  28.         ++num;
  29.         A = (a[0] * num) / (min);
  30.         if (A != floor(A)) continue;
  31.         B = (a[1] * num) / (min);
  32.         if (B != floor(B)) continue;
  33.         C = (a[2] * num) / (min);
  34.         if (C != floor(C)) continue;
  35.         D = (a[3] * num) / (min);
  36.         if (D != floor(D)) continue;
  37.         E = (a[4] * num) / (min);
  38.         if (E != floor(E)) continue;
  39.  
  40.         int sum = A+B+C+D+E;
  41.         cout << sum;
  42.         break;
  43.        
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement