题意:

求1~2^64-1之间所有的 至少是两个不同的正整数的幂的数  升序输出

一个数的合数次幂即为这样的数

找出1~2^64-1中所有数的合数次幂 用set存起来(既能防止重复 又能升序) 最后输出就好了

#include <iostream>
#include <cstdio>
#include <sstream>
#include <cstring>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include <climits>
#define MOD 2018
#define LL long long
#define ULL unsigned long long
#define Pair pair<int, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define _ ios_base::sync_with_stdio(0),cin.tie(0)
//freopen("1.txt", "r", stdin);
using namespace std;
const int maxn = , INF = 0x7fffffff;
LL vis[maxn];
int ans;
set<ULL> s; ULL power(ULL a, ULL b) { //快速幂
ULL res = ;
while(b)
{
if(b & ) res = res * a;
a = a * a;
b >>= ;
}
return res;
}
//ULL power(int a, int b) //二分幂
//{
// if(b == 0) return 1;
// ULL res = power(a, b/2);
// res *= res;
// if(b & 1) res *= a;
// return res;
//} void init()
{
ans = ;
mem(vis, );
for(int i=; i<=; i++)
if(!vis[i])
{
for(LL j=(LL)i*i; j<=; j+=i)
vis[j] = ;
}
} int main()
{
init();
s.insert(); for(ULL i=; i< (<<); i++)
{
double t=ceil(64.0/log(i)*log())-; for(int j=; j<=; j++)
{
if(!vis[j])continue;
if(j> t) break;
ULL res = power(i, j);
s.insert(res);
}
}
for(set<ULL>::iterator it=s.begin(); it!=s.end(); it++)
printf("%llu\n",*it); return ;
}

The Super Powers UVA - 11752(合数幂)的更多相关文章

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

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

  2. The Super Powers UVA - 11752

    题目大意:将范围从1~pow(2,64)-1内的super power输出.super power的定义:一个数x至少存在两种x=pow(i,k),(k!=1). 题解: 注意数据范围2的64次方-1 ...

  3. UVa 11752 (素数筛选 快速幂) The Super Powers

    首先有个关键性的结论就是一个数的合数幂就是超级幂. 最小的合数是4,所以枚举底数的上限是pow(2^64, 1/4) = 2^16 = 65536 对于底数base,指数的上限就是ceil(64*lo ...

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

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

  5. The Super Powers

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

  6. UVA11752 The Super Powers

    /* UVA11752 The Super Powers https://vjudge.net/contest/153365#problem/Y 数论 注意a^n=b要用除法求,并且求得的n比实际大1 ...

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

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

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

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

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

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

随机推荐

  1. day59

    轮播图作业 <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF ...

  2. DB2创建视图view

    create view v_table1(col1,col2,col3...)--视图名(字段一,字段二,字段三...) as --后跟查询语句 select col1,col2,col3... fr ...

  3. SAP查询TABLE对应的文本表

    SAP 取数时,通常配置项,需要取对应的文本描述,一般在配置表后加个T,就可以找到描述对应的表名. 但有时也有不符合这个规则的,例如生产订单类型数据表 T003O. 表名加T后并不存T003OT. 这 ...

  4. Ubuntu14.04配置gcc4.4.4+Qt4.8.4交叉编译环境

    安装32位程序运行支持 sudo apt-get install lib32stdc++6 lib32z1 lib32ncurses5 lib32bz2-1.0 可能报错: lib32stdc++6 ...

  5. vlc播放rtsp之怪事

    播放源:rtsp;//admin:12345@11.11.3.24:554/Streaming/channels/201 源是一台海康的nvr,在一台win2003的服务器用vlc2.2可以播放,但在 ...

  6. China Internet Conference(2018.07.12)

    中国互联网大会 时间:2018.07.12地点:北京国家会议中心

  7. DDD China Conference 2017

    DDD China Conference 2017 时间:2017.12.9地点:国际会议中心

  8. 20155306 白皎 《网络攻防》 EXP8 Web基础

    20155306 白皎 <网络攻防> EXP8 Web基础 一.问题回答 - 什么是表单 表单:一般用来收集用户的信息和反馈意见 表单包括两个部分:一部分是HTML源代码用于描述表单(例如 ...

  9. HTTPUTILS

    maven依赖 <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId&g ...

  10. lnmp如何实现伪静态,默认目录伪静态

    LNMP一键安装包一直是我小内存VPS的首选安装环境,因为它占用资源少,性能高.最新发布的lnmp0.7还增加了对LNMPA的支持,LNMPA使用Nginx作为前端服务能够更快更及时的静态页面.js. ...