uva 11752 -The Super Powers (数论)

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;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值