Skip to content

Instantly share code, notes, and snippets.

@surinoel
Created September 14, 2019 08:28
Show Gist options
  • Save surinoel/7abae1ac1c488fc4bc15d628f9950081 to your computer and use it in GitHub Desktop.
Save surinoel/7abae1ac1c488fc4bc15d628f9950081 to your computer and use it in GitHub Desktop.
#include <cmath>
#include <iostream>
using namespace std;
double v[300000];
int main(void) {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> v[i];
}
double ans = v[n - 1];
for (int i = n - 2; i >= 0; i--) {
ans = ceil(ans / v[i]) * v[i];
}
cout << (long long)ans << '\n';
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment