UVa : 443


// @BEGIN_OF_SOURCE_CODE

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <sstream>
#include <set>
#include <math.h>
#define N 1000000
using namespace std;


int main ()
{
    set <double> H;
    H.insert (1);
    set <double> :: iterator it = H.begin ();

    while ( H.size () < 7000 ) {
        H.insert (*it * 2);
        H.insert (*it * 3);
        H.insert (*it * 5);
        H.insert (*it * 7);
        *it++;
    }

    vector <double> v (H.begin (), H.end ());

    int input;

    while ( scanf ("%d", &input) && input ) {
        char str [5];

        if ( input % 10 == 1 && (input % 100) / 10 != 1 )
            strcpy (str, "st");
        else if ( input % 10 == 2 && (input % 100) / 10 != 1 )
            strcpy (str, "nd");
        else if ( input % 10 == 3 && (input % 100) / 10 != 1)
            strcpy (str, "rd");
        else
            strcpy (str, "th");

        printf ("The %d%s humble number is %0.lf.\n", input, str, v [input - 1]);
    }

    return 0;
}

// @END_OF_SOURCE_CODE

One thought on “UVa : 443

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s