Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define el endl
- const int mod = 1e9 + 7;
- using namespace std;
- void solve()
- {
- int n;
- cin >> n;
- int a[n];
- int sum1 = 0;
- for(int i = 0; i < n; i++)
- {
- cin >> a[i];
- sum1 += a[i];
- }
- sort(a, a + n);
- int b[n];
- int base = a[0];
- while(base > 0)
- {
- bool ok = true;
- b[0] = a[0] / base;
- for(int i = 1; i < n; i++)
- {
- b[i] = a[i] / base;
- }
- for(int i = 0; i < n; i++)
- {
- if(base != a[i] / b[i])
- {
- ok = false;
- break;
- }
- }
- if(ok)
- {
- break;
- }
- base--;
- }
- for(int i = 0; i < n; i++)
- while( b[i] - 1 > 0 && a[i] / (b[i] - 1) == base)
- {
- b[i]--;
- }
- int res = 0;
- if(base)
- {
- for(int i = 0; i < n; i++)
- {
- // cout<<b[i]<<" ";
- res += b[i];
- }
- cout << res;
- }
- }
- int main()
- {
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement