Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- #define read() freopen("input.txt", "r", stdin)
- #define write() freopen("output.txt", "w", stdout)
- ll mx = 2000000009;
- vector<ll>humble;
- map<ll,bool>mp;
- int a[4]={2,3,5,7};
- void gethumble(ll n){
- if(n>mx || mp[n]) return;
- humble.push_back(n);
- mp[n] = true;
- for(int i=0;i<4;i++){
- gethumble(a[i]*n);
- }
- }
- string getst(int n)
- {
- if(n%10==1 && (n/10)%10!=1) return "st";
- else if(n%10==2 && (n/10)%10!=1) return "nd";
- else if(n%10==3 && (n/10)%10!=1) return "rd";
- else return "th";
- }
- int main()
- {
- gethumble(1);
- sort(humble.begin(),humble.end());
- ll n;
- while(cin>>n && n){
- cout<<"The "<<n<<getst(n)<<" humble number is "<<humble[n-1]<<".\n";
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement