The Super Powers
| Time Limit: 1000MS | Memory Limit: Unknown | 64bit IO Format: %lld & %llu |
Description
|
A |
The Super Powers |
We all know the Super Powers of this world and how they manage to get advantages in political warfare or even in other sectors. But this is not a political platform and so we will talk about a different kind of super powers – “The Super Power Numbers”. A positive number is said to be super power when it is the power of at least two different positive integers. For example 64 is a super power as 64 = 82 and 64 = 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 |
Partial Judge Output |
No input for this problem |
1 16 81 512 |
#include<stdio.h>
#include<string.h>
#include<set>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define ll unsigned long long
int a[]= {},nu;
void init()
{
int i,j;
nu=;
for(i=; i<; i++)
{
if(!a[i])
{
j=i*i;
while(j<)
{
a[j]=;
j+=i;
}
}
}
j=;
for(i=; i<; i++)if(a[i])a[j++]=i;
//for(i=0; i<j; i++)cout<<a[i]<<endl;
nu=j;
}
ll powLL(ll x, ll y)
{
ll ans=;
while(y)
{
if(y&)
ans*=x;
x*=x;
y>>=;
}
return ans;
}
int main()
{
init();
int i,j,size;
ll maxa=~0ULL,n;
//cout<<maxa<<endl;
set<ll>aa;
aa.clear();
aa.insert();
for(i=;;i++)
{
size=;
n=maxa;
while(n>=i) n/=i,size++;
if(size<) break;
for(j=;j<nu;j++)
{
if(a[j]<=size)
aa.insert(powLL(i, a[j]));
else break;
}
}
for(set<ll>::iterator it=aa.begin();it!=aa.end();it++)
printf("%llu\n",*it);
}
The Super Powers的更多相关文章
- The Super Powers UVA 11752 分析分析 求无符号长整形以内的数满足至少可以用两种不同的次方来表示。比如64 = 2^6 = 8^2; 一个数的1次方不算数。
/** 题目:The Super Powers UVA 11752 链接:https://vjudge.net/contest/154246#problem/Y 题意:求无符号长整形以内的数满足至少可 ...
- uva 11752 The Super Powers 素数+大数判断大小
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- UVA11752 The Super Powers
/* UVA11752 The Super Powers https://vjudge.net/contest/153365#problem/Y 数论 注意a^n=b要用除法求,并且求得的n比实际大1 ...
- The Super Powers UVA - 11752
题目大意:将范围从1~pow(2,64)-1内的super power输出.super power的定义:一个数x至少存在两种x=pow(i,k),(k!=1). 题解: 注意数据范围2的64次方-1 ...
- uva 11752 - The Super Powers
这个题 任意一个数,他的幂只要不是质数则可以分解成两个数的乘 判断有没有溺出 i×i 则用最大的那个数 Max/i < i 吗 #include<iostream> #i ...
- UVa 11752 (素数筛选 快速幂) The Super Powers
首先有个关键性的结论就是一个数的合数幂就是超级幂. 最小的合数是4,所以枚举底数的上限是pow(2^64, 1/4) = 2^16 = 65536 对于底数base,指数的上限就是ceil(64*lo ...
- UVa 11752 - The Super Powers 数学
请看这个说明http://blog.csdn.net/u014800748/article/details/45914353 #define _CRT_SECURE_NO_WARNINGS #incl ...
- The Super Powers UVA - 11752(合数幂)
题意: 求1~2^64-1之间所有的 至少是两个不同的正整数的幂的数 升序输出 一个数的合数次幂即为这样的数 找出1~2^64-1中所有数的合数次幂 用set存起来(既能防止重复 又能升序) 最后输 ...
- uva 11752 The Super Powers (数论+枚举)
题意:找出1~2^64-1中 能写成至少两个数的幂形式的数,再按顺序输出 分析:只有幂是合数的数才是符合要求的.而幂不会超过64,预处理出64以内的合数. 因为最小的合数是4,所以枚举的上限是2的16 ...
随机推荐
- 网上搜索到的 比较好的mysql查询语句练习题
Sutdent表的定义 字段名 字段描述 数据类型 主键 外键 非空 唯一 自增 Id 学号 INT(10) 是 否 是 是 是 Name 姓名 VARCHAR(20) 否 否 是 否 否 Sex 性 ...
- LVS之DR跨网段实战及高可用性
author:JevonWei 版权声明:原创作品 LVS-DR实现跨网段 网络拓扑 网络环境 RS1 RIP 192.168.198.138/24 VIP 192.168.80.100/32 GW ...
- chrome开发工具指南(十三)
模拟传感器:地理定位与加速度计 由于大多数桌面设备都没有 GPS 芯片和加速度计,所以测试它们比较困难.Chrome DevTools 的 Sensors 模拟窗格可以通过模拟常见的移动设备传感器来降 ...
- spring事务详解
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt122 Spring事务机制主要包括声明式事务和编程式事务,此处侧重讲解声明式 ...
- 在Android上仿百度贴吧客户端Loading图标小球
封面 前言 使用百度贴吧客户端的时候发发现加载的小动画挺有意思的,于是自己动手写写看.想学习自定义View以及自定义动画的小伙伴一定不要错过哦. 读者朋友需要有最基本的canvas绘图功底,比如画笔P ...
- 建立maven工程pom.xml报错:web.xml is missing and <failOnMissingWebXml> is set to true
解决方式:如图添加web.xml文件即可
- 【1414软工助教】团队作业8——第二次项目冲刺(Beta阶段) 得分榜
题目 团队作业8--第二次项目冲刺(Beta阶段) 往期成绩 个人作业1:四则运算控制台 结对项目1:GUI 个人作业2:案例分析 结对项目2:单元测试 团队作业1:团队展示 团队作业2:需求分析&a ...
- 团队作业4——第一次项目冲刺(Alpha版本)6th day
一.Daily Scrum Meeting照片 二.燃尽图 三.项目进展 24点的游戏输入是点击我们给的图片然后会输入相应的数字,之前的所做的出 现了一点问题,在把数字删掉重新输入就不行,这个问题仍然 ...
- 201521123061 《Java程序设计》第七周学习总结
201521123061 <Java程序设计>第七周学习总结 1. 本周学习总结 2. 书面作业 ArrayList代码分析 1.1 解释ArrayList的contains源代码 贴上源 ...
- 201521123101 《Java程序设计》第4周学习总结
1. 本周学习总结 1.1 尝试使用思维导图总结有关继承的知识点. 1.2 使用常规方法总结其他上课内容. 理解类的继承的概念,明白父与子之间关系的 2. 书面作业 1.注释的应用,使用类的注释与方法 ...