HDU : The number of divisors about Humble Numbers


// @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 <set>
#include <math.h>
#define For(i, a) for ( i = 0; i < a; i++ )
#define Rep(i, a, b) for ( i = a; i <= b; i++ )
#define N 1000000
using namespace std;


int main ()
{
    long long n;

    while ( cin >> n && n ) {
        int divisors = 1;
        int count = 0;

        while ( n % 2 == 0 ) {
            count++;
            n /= 2;
        }

        divisors *= (count + 1);
        count = 0;

        while ( n % 3 == 0 ) {
            count++;
            n /= 3;
        }

        divisors *= (count + 1);
        count = 0;

        while ( n % 5 == 0 ) {
            count++;
            n /= 5;
        }

        divisors *= (count + 1);
        count = 0;

        while ( n % 7 == 0 ) {
            count++;
            n /= 7;
        }

        divisors *= (count + 1);

        printf ("%d\n", divisors);

    }

    return 0;
}

// @END_OF_SOURCE_CODE
Advertisements

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