Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <math.h>
- using namespace std;
- double a[5];
- double A, B, C, D, E;
- int main()
- {
- ios::sync_with_stdio(false);
- cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
- sort(begin(a),end(a));
- int min = 0;
- for (int i = 0;i<5;++i)
- {
- if (a[i] != 0) { min = a[i];break; }
- }
- int num = 0;
- while (true)
- {
- ++num;
- A = (a[0] * num) / (min);
- if (A != floor(A)) continue;
- B = (a[1] * num) / (min);
- if (B != floor(B)) continue;
- C = (a[2] * num) / (min);
- if (C != floor(C)) continue;
- D = (a[3] * num) / (min);
- if (D != floor(D)) continue;
- E = (a[4] * num) / (min);
- if (E != floor(E)) continue;
- int sum = A+B+C+D+E;
- cout << sum;
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement