Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
136
SUBMITTED BY:
Guest
DATE:
Dec. 25, 2013, 3:06 p.m.
FORMAT:
Text only
SIZE:
507 Bytes
Raw
Download
Tweet
HITS:
1986
Go to comments
Report
#include <cstdio>
#include <set>
using namespace std;
int main()
{
set<int> s;
set<int>::iterator it;
s.insert(1);
for (int i = 1; i < 1500; ++i)
{
it = s.begin();
/*printf("%d %d\n", i+1, *it);*/
if (*it*2 > 0)
s.insert(*it*2);
if (*it*3 > 0)
s.insert(*it*3);
if (*it*5 > 0)
s.insert(*it*5);
s.erase(*it);
}
it = s.begin();
printf("The 1500'th ugly number is %d.\n", *it);
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus