Advertisement
Guest User

Untitled

a guest
Jan 14th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. ifstream in("2x3y5z.in");
  6. ofstream out("2x3y5z.out");
  7.  
  8. int n, c2, c3, c5;
  9. vector <long long> v;
  10.  
  11. int main() {
  12. in >> n;
  13. if (n == 1)
  14. return out << 1, 0;
  15. v.emplace_back(1);
  16. for (int i = 1; i < n; ++i) {
  17. long long next = min(2 * v[c2], min(3 * v[c3], 5 * v[c5]));
  18. v.emplace_back(next);
  19. if (next == 2 * v[c2]) ++c2;
  20. if (next == 3 * v[c3]) ++c3;
  21. if (next == 5 * v[c5]) ++c5;
  22. }
  23. return out << v[(int)v.size() - 1], 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement