1095 - table.insert(value); } value = n*7; if(value>0...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include<cstdio> #include<queue> #include<vector> #include<algorithm> #include<set> # using namespace std; u enum { Size = 5842, }; } long long humble[Size]; int pos; i void init(){ long long n; long long value; set<long long> table; priority_queue<long long, vector<long long>, greater<long long> > que; pos = 0; que.push(1ll); table.insert(1ll); t while(pos < Size){ n = que.top(); que.pop(); humble[pos ++] = n; h value = n*2; que.push(value); table.insert(value); } value = n*3; que.push(value); table.insert(value); } value = n*5; que.push(value);
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: table.insert(value); } value = n*7; if(value>0 && table.find(value) == table.end()){ que.push(value); table.insert(value); } } } void printnumber(int n){ int suff; int oct; suff = n %10; oct = n %100; if(suff ==0 || suff>3 || (oct >10 && oct <14) ){ printf("%dth", n); return; } if(suff ==1){ printf("%dst", n); } else if(suff==2){ printf("%dnd", n); } else { printf("%drd", n); } } int main(){ int num; int index; init(); scanf("%d", &index); while(index ){ num = humble[index-1]; n printf("The "); printnumber(index); printf(" humble number is %d.\n", num); p scanf("%d", &index); } return 0; }...
View Full Document

This note was uploaded on 02/18/2010 for the course CS 100 taught by Professor Acm during the Spring '10 term at Zhejiang University.

Page1 / 2

1095 - table.insert(value); } value = n*7; if(value>0...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online