136


SUBMITTED BY: Guest

DATE: Dec. 25, 2013, 3:06 p.m.

FORMAT: Text only

SIZE: 507 Bytes

HITS: 1986

  1. #include <cstdio>
  2. #include <set>
  3. using namespace std;
  4. int main()
  5. {
  6. set<int> s;
  7. set<int>::iterator it;
  8. s.insert(1);
  9. for (int i = 1; i < 1500; ++i)
  10. {
  11. it = s.begin();
  12. /*printf("%d %d\n", i+1, *it);*/
  13. if (*it*2 > 0)
  14. s.insert(*it*2);
  15. if (*it*3 > 0)
  16. s.insert(*it*3);
  17. if (*it*5 > 0)
  18. s.insert(*it*5);
  19. s.erase(*it);
  20. }
  21. it = s.begin();
  22. printf("The 1500'th ugly number is %d.\n", *it);
  23. return 0;
  24. }

comments powered by Disqus