题目: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. html5 WebSocket的Js实例教程

    详细解读一个简单+ ,附带完整的javascript websocket实例源码,以及实例代码效果演示页面,并对本实例的核心代码进行了深入解读. 从WebSocket通讯三个阶段(打开握手.数据传递. ...

  2. boost的libboost_system问题

    最近把cpp代码从开发机放到eclipse时,遇到了不少路径问题. 安装boost的时候,其实很简单 wget http://sourceforge.net/projects/boost/files/ ...

  3. oracle--二维表的操作创建修改删除

    oracle学习内容 oracle的管理系统学习 oracle的数据管理学习 oracle的用户管理 oracle二维表管理 创建表和字段讲解 --创建表学习 1. 创建表的基本语句:create t ...

  4. [Git] 010 对 [Git 008] 的补充:实现 commit 不计次数

    回顾:[Git] 008 status 与 commit 命令的补充 的 "2.4" [Git 008] 的 "2.4" 使用 git commit --ame ...

  5. 《剑指offer》面试题19 二叉树的镜像 Java版

    书中方法:这道题目可能拿到手没有思路,我们可以在纸上画出简单的二叉树来找到规律.最后我们发现,镜像的实质是对于二叉树的所有节点,交换其左右子节点.搞清楚获得镜像的方法,这道题实际上就变成了一道二叉树遍 ...

  6. [BZOJ 2199] [USACO11JAN] 大陆议会The Continental Cowngress(2-SAT)

    [BZOJ 2199] [USACO11JAN] 大陆议会The Continental Cowngress(2-SAT) 题面 题面较长,略 分析 考虑把问题转化成一个依赖性问题 我们把每只奶牛投出 ...

  7. 给定两个list A ,B,请用找出 A ,B中相同的元素,A ,B中不同的元素 ??

    A.B 中相同元素:print(set(A)&set(B)) A.B 中不同元素:print(set(A)^set(B))

  8. 1、获取ip地址

    1.获取ip地址 System.Net.NetworkInformation.NetworkInterface.GetAllNetworkInterfaces() .Select(p => p. ...

  9. zabbix 4.2 发送警告邮件Python脚本

    #!/usr/bin/env python#-*- coding: UTF-8 -*-import os,sysimport getoptimport smtplibfrom email.MIMETe ...

  10. Oracle Set操作

    并集合 union/uinon all union 会去重,uinon all 不去重 交集 intersect 差集 minus