UVA 11752 The Super Powers【超级幂】
题目链接:
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=111527#problem/Z
题意:
我们称一个可以由至少两个不同正整数的幂的形式表示的数为超级幂。让你找出1到264−1之间的所有超级幂。
分析:
首先ax∗y=axy,也就是说超级幂必须存在一个为合数的指数。
底数最小为2,此时指数最大为64。
指数最小为4,此时底数最小为216。
暴力枚举一发即可。
因为ull的最大值为264−1,所以乘的过程中注意判断是否大于边界。
代码:
#include <iostream>
#include<set>
#include<cstdio>
using namespace std;
const int mod = 1e9 + 7, maxn = 64 + 5;
bool isprime[maxn];
#define ull unsigned long long
ull INF = (1<<64) - 1;
set<ull>s;
void getprime()
{
int n = 64;
fill(isprime, isprime + n, 1);
for(int i = 2; i * i <= n; i++){
if(isprime[i]){
for(int j = 2 * i; j <= n; j += i){
isprime[j] = false;
}
}
}
}
int main (void)
{
getprime();
for(int i = 2; i <= 65536; i++){
ull ans = 1;
for(int j = 1; j <= 64; j++){
ans *= i;
if(!isprime[j]) s.insert(ans);
if(ans > INF / i) break;
}
}
s.insert(1);
set<ull>::iterator a;
for(a = s.begin(); a != s.end(); a++)
cout<<*a<<endl;
return 0;
}
UVA 11752 The Super Powers【超级幂】的更多相关文章
- uva 11752 The Super Powers 素数+大数判断大小
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- UVA 11752 The Super Powers —— 数学与幂
题目链接:https://vjudge.net/problem/UVA-11752 题解: 1.首先变量必须用unsig long long定义. 2.可以分析得到,当指数为合数的时候,该值合法. 3 ...
- uva 11752 - The Super Powers
这个题 任意一个数,他的幂只要不是质数则可以分解成两个数的乘 判断有没有溺出 i×i 则用最大的那个数 Max/i < i 吗 #include<iostream> #i ...
- uva 11752 The Super Powers (数论+枚举)
题意:找出1~2^64-1中 能写成至少两个数的幂形式的数,再按顺序输出 分析:只有幂是合数的数才是符合要求的.而幂不会超过64,预处理出64以内的合数. 因为最小的合数是4,所以枚举的上限是2的16 ...
- UVA 11752 The Super Powers(暴力)
题目:https://cn.vjudge.net/problem/UVA-11752 题解:这里只讨论处理越界的问题. 因为题目最上界是 264-1. 我们又是求次幂的. 所以当我们就可以知道 i 的 ...
- UVa 11752 - The Super Powers 数学
请看这个说明http://blog.csdn.net/u014800748/article/details/45914353 #define _CRT_SECURE_NO_WARNINGS #incl ...
- UVa 11752 (素数筛选 快速幂) The Super Powers
首先有个关键性的结论就是一个数的合数幂就是超级幂. 最小的合数是4,所以枚举底数的上限是pow(2^64, 1/4) = 2^16 = 65536 对于底数base,指数的上限就是ceil(64*lo ...
- The Super Powers UVA 11752 分析分析 求无符号长整形以内的数满足至少可以用两种不同的次方来表示。比如64 = 2^6 = 8^2; 一个数的1次方不算数。
/** 题目:The Super Powers UVA 11752 链接:https://vjudge.net/contest/154246#problem/Y 题意:求无符号长整形以内的数满足至少可 ...
- BZOJ1709: [Usaco2007 Oct]Super Paintball超级弹珠
1709: [Usaco2007 Oct]Super Paintball超级弹珠 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 324 Solved: ...
随机推荐
- mac下安装nodejs
下载 https://nodejs.org/en/ 安装 一步步继续就ok 验证 npm -v node -v Done!
- android 图片叠加效果——两种方法的简介与内容 ,带解决Immutable bitmap passed to Canvas constructor错误
第一种是通过canvas画出来的效果: public void first(View v) { // 防止出现Immutable bitmap passed to Canvas constructor ...
- 洛谷 P1802 5倍经验日
题目背景 现在乐斗有活动了!每打一个人可以获得5倍经验!absi2011却无奈的看着那一些比他等级高的好友,想着能否把他们干掉.干掉能拿不少经验的. 题目描述 现在absi2011拿出了x个迷你装药物 ...
- ECharts是我接触过的最优秀的可视化工具,也是进步最快的软件,希望它早日成为世界级的开源项目。
ECharts的广泛网址: http://echarts.baidu.com/doc/example.html 零编程玩转图表: http://tushuo.baidu.com/?qq-pf-to=p ...
- vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示
vue :class 可以接收 字符串 数组 和 对象 对象里面的key值 根据true或false 显示不显示 https://cn.vuejs.org/v2/guide/class-and-sty ...
- 洛谷 P1518 两只塔姆沃斯牛
P1518 两只塔姆沃斯牛 The Tamworth Two 简单的模拟题,代码量不大. 他们走的路线取决于障碍物,可以把边界也看成障碍物,遇到就转,枚举次,因为100 * 100 * 4,只有4个可 ...
- SQL语句新建数据库
CREATE DATABASE 语句. CREATE DATABASE Epiphany ON ( NAME = Epiphany, FILENAME = 'E:\SQL SERVER 2008\Ep ...
- CSS--基础结构层叠
权值:通配符*的权值为0,标签和伪元素的权值为1,类选择符,属性选择器或伪类的权值为10,ID选择符的权值为100,内联样式最高为1000.还有一个权值比较特殊--继承也有权值但很低,有的文献提出它只 ...
- python re 正则表达式
元字符和其含义 . 匹配除换行符以外的任意字符 \ 转义字符,使后一个字符改变原来的意思 \w 匹配字母.数字.下划线:[A-Za-z0-9_] \W 匹配特殊字符:[^A-Za-z0-9_] \s ...
- LeetCode(16)3Sum Closest
题目 Given an array S of n integers, find three integers in S such that the sum is closest to a given ...