Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- ifstream in("2x3y5z.in");
- ofstream out("2x3y5z.out");
- int n, c2, c3, c5;
- vector <long long> v;
- int main() {
- in >> n;
- if (n == 1)
- return out << 1, 0;
- v.emplace_back(1);
- for (int i = 1; i < n; ++i) {
- long long next = min(2 * v[c2], min(3 * v[c3], 5 * v[c5]));
- v.emplace_back(next);
- if (next == 2 * v[c2]) ++c2;
- if (next == 3 * v[c3]) ++c3;
- if (next == 5 * v[c5]) ++c5;
- }
- return out << v[(int)v.size() - 1], 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement