We all know the Super Powers of this world and how they manage to get advantages in political warfareor even in other sectors. But this is not a political platform and so we will talk about a different kindof super powers — "The Super Power Numbers". A positive number is said to be super power when itis the power of at least two different positive integers. For example 64 is a super power as 64 = 82 and64 = 43. You have to write a program that lists all super powers within 1 and 264 ? 1 (inclusive)
Input
This program has no input.
Output
Print all the Super Power Numbers within 1 and 2^64 -1. Each line contains a single super power number and the numbers are printed in ascending order.
Sample Input
No input for this problem
Partial Judge Output
1
16
64
81
256
512
.
.
.
题目大意:超级幂(要求要打到1-2^64 -1的数,该数是两个或以上的正整数的幂次方),没有输入,只有输出打表!
思路:首先想到了素数的合数次方,最小的合数(也就是幂)是4,那么最大的底数(也就是要打的素数表的最大值是2^16,也就是1<<16,开到65536的数组足够),按照这种思路,却T了很多次,最后问学长,才知道打的时候没有判断,到最后打的太多反而T了,加判断的方法是判断指数要小于ceil(64.0/log(i)*log(2)),按说到此应该Ac了,可是又wa了一次,原来一开始推错了,应该打所有数的合数次方,最后去重即可,表示用vector打素数的合数次方打的好伤心,正解用set/map存,去重和排序一体。
code:
# include<iostream>
# include<cstdio>
# include<cstring>
# include<set>
# include<cmath>
# include<algorithm>
using namespace std;
typedef unsigned long long ull;