#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""Project Euler: 0029

https://projecteuler.net/problem=29

Distinct powers

Consider all integer combinations of

a^b for 2 ≤ a ≤ 5 and 2 ≤ b ≤ 5:

2²=4, 2³=8, 2⁴=16, 2⁵=32

3²=9, 3³=27, 3⁴=81, 3⁵=243

4²=16, 4³=64, 4⁴=256, 4⁵=1024

5²=25, 5³=125, 5⁴=625, 5⁵=3125

If they are then placed in numerical order, with any repeats removed, we get
the following sequence of 15 distinct terms:

4, 8, 9, 16, 25, 27, 32, 64, 81, 125, 243, 256, 625, 1024, 3125

How many distinct terms are in the sequence generated by a^b for 2 ≤ a ≤ 100
and 2 ≤ b ≤ 100?
"""

import itertools

PROBLEM = 29
SOLVED = True
SPEED = 0.04
TAGS = ['powers', 'unique', 'set']


def main():
    """Solve problem."""
    print 'Project Euler: %04d' % PROBLEM
    distinct = set()
    for num, power in itertools.product(xrange(2, 101), repeat=2):
        distinct.add(num ** power)
    print len(distinct)


if __name__ == '__main__':
    main()
