题目:https://cn.vjudge.net/problem/UVA-11752

题解:这里只讨论处理越界的问题。

   因为题目最上界是 264-1。 我们又是求次幂的。

   所以当我们就可以知道 i 的时候的界限 limit = 264-1 / i。如果刚好前一个次幂是 limit,那么再乘一个 i 刚好等于 264-1,按照题意是符合的。

   那么如果当前的 次幂 a 是大于 limit 的话,a*i 就一定越界(可以自己想一想为什么),这个时候就可以break了。

  这一题用set 保存,因为set中不会出现重复元素,而且元素是从小到大的顺序排列的。

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
const LL INF = 0x7fffffff;
const int inf = 0x3f3f3f3f;
const int mod = 1e9+;
const int maxn = +;
const int maxm = +;
bool heshu[maxn];
set<uLL> ans;
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
// ios::sync_with_stdio(0);
// cin.tie(0);
ms(heshu, false);
for(int i = ;*i<;i++){
for(int j = ;i*j<;j++)
heshu[i*j]=true;
}
uLL top = (<<)-1uLL;
for(uLL i = 2uLL;i<65536uLL;i++){
uLL limit = top / i;
uLL now = 1uLL*i*i*i*i;
for(int j = ;j<;j++){
if(heshu[j])
ans.insert(now);
if(now>limit) break;
now*=i;
}
}
ans.insert(1uLL);
set<uLL>::iterator q;
for(q = ans.begin();q!=ans.end();q++)
cout << *q << endl;
// cout << ans.size() << endl;
}

UVA 11752 The Super Powers(暴力)的更多相关文章

  1. uva 11752 The Super Powers 素数+大数判断大小

    题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...

  2. UVA 11752 The Super Powers【超级幂】

    题目链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=111527#problem/Z 题意: 我们称一个可以由至少两个不同正整数的幂 ...

  3. uva 11752 - The Super Powers

    这个题   任意一个数,他的幂只要不是质数则可以分解成两个数的乘   判断有没有溺出  i×i  则用最大的那个数 Max/i < i 吗 #include<iostream> #i ...

  4. UVa 11752 - The Super Powers 数学

    请看这个说明http://blog.csdn.net/u014800748/article/details/45914353 #define _CRT_SECURE_NO_WARNINGS #incl ...

  5. uva 11752 The Super Powers (数论+枚举)

    题意:找出1~2^64-1中 能写成至少两个数的幂形式的数,再按顺序输出 分析:只有幂是合数的数才是符合要求的.而幂不会超过64,预处理出64以内的合数. 因为最小的合数是4,所以枚举的上限是2的16 ...

  6. UVA 11752 The Super Powers —— 数学与幂

    题目链接:https://vjudge.net/problem/UVA-11752 题解: 1.首先变量必须用unsig long long定义. 2.可以分析得到,当指数为合数的时候,该值合法. 3 ...

  7. The Super Powers UVA 11752 分析分析 求无符号长整形以内的数满足至少可以用两种不同的次方来表示。比如64 = 2^6 = 8^2; 一个数的1次方不算数。

    /** 题目:The Super Powers UVA 11752 链接:https://vjudge.net/contest/154246#problem/Y 题意:求无符号长整形以内的数满足至少可 ...

  8. UVA 10622 - Perfect P-th Powers(数论)

    UVA 10622 - Perfect P-th Powers 题目链接 题意:求n转化为b^p最大的p值 思路:对n分解质因子,然后取全部质因子个数的gcd就是答案,可是这题有个坑啊.就是输入的能够 ...

  9. The Super Powers

    The Super Powers Time Limit: 1000MS   Memory Limit: Unknown   64bit IO Format: %lld & %llu [Subm ...

随机推荐

  1. js数组,运算符

  2. [12期]Mysql案例分析

    腾讯视频源:http://v.qq.com/vplus/0ef1d6371912bf6d083dce956f48556c 访问新闻版块,去掉?ID=X的参数以后报错 参数去掉,没有报错,显示正常,说明 ...

  3. linux下的SSHD被连接端口修改

    连接别人:vim /etc/ssh/ssh_config 被连接: vim /etc/ssh/sshd_config 端口重启生效: /etc/init.d/sshd restart

  4. [常用类]排序及Arrays类(简单介绍)

    冒泡排序bubble sort  轻的上浮,重的下沉.两个相邻位置比较,如果前面元素比后面的元素大就换位置 选择排序 select sort 用一个索引上的元素,依次和其他位置上的元素比较,小的放前面 ...

  5. NameVirtualHost的使用

    如果某个ip:port 上只设置了一个虚拟主机,那么NameVirtualHost ip:port 可以不写,因为从这个ip:port的访问不需要做任何选择:如上例中192.168.1.197只对应于 ...

  6. TP5.1+Vue前后端分离实践

    配置: 主域名 www.demo.xyz 二级子域名 api.demo.xyz 列表项目其中api.demo.xyz加入了版本控制,使用的是URL路由传入方式 在route.php路由文件中配置,如下 ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) D. Magic Gems(矩阵快速幂)

    题目传送门 题意: 一个魔法水晶可以分裂成m个水晶,求放满n个水晶的方案数(mol1e9+7) 思路: 线性dp,dp[i]=dp[i]+dp[i-m]; 由于n到1e18,所以要用到矩阵快速幂优化 ...

  8. 如何将datetimepicker默认设置为空?

    在Load中,初始化 this.dateTimePicker1.Format=DateTimePickerFormat.Custom; his.dateTimePicker1.CustomFormat ...

  9. 7、前端知识点--关于Array.from详解

    1.Array.from()方法就是将一个类数组对象 或 可遍历对象 或 可迭代对象 转换成一个真正的数组.浅拷贝的数组实例. 2.那么,什么是类数组对象呢?所谓类数组对象,最基本的要求就是具有len ...

  10. neovim初次安装使用

    github下载neovim代码 按readme中安装,中间可能 要安装一些库 将vim的配置关联到nvim,发现和vim是一样的 ln -s ~/.vim ~/.config/nvim ln -s ...