[ create a new paste ] login | about

Link: http://codepad.org/QQfKglM7    [ raw code | output | fork ]

C++, pasted on Sep 17:
#include <cstdio>
#include <queue>
using namespace std;

const int DNUM = 16;

int main(void)
{
    int pre = 0, i = 0;
    priority_queue<int, vector<int>, greater<int> > pq;
    pq.push(1);
    
    while(i < DNUM)
    {
        int a = pq.top();
        pq.pop();
        if(a == pre) continue;
        
        printf("%d\n", a);
        pq.push(a * 2);
        pq.push(a * 3);
        pq.push(a * 5);
        
        pre = a;
        i++;
    }
    
    return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1
2
3
4
5
6
8
9
10
12
15
16
18
20
24
25


Create a new paste based on this one


Comments: