The Super Powers UVA - 11752(合数幂)
题意:
求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(合数幂)的更多相关文章
- The Super Powers UVA 11752 分析分析 求无符号长整形以内的数满足至少可以用两种不同的次方来表示。比如64 = 2^6 = 8^2; 一个数的1次方不算数。
/** 题目:The Super Powers UVA 11752 链接:https://vjudge.net/contest/154246#problem/Y 题意:求无符号长整形以内的数满足至少可 ...
- 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
首先有个关键性的结论就是一个数的合数幂就是超级幂. 最小的合数是4,所以枚举底数的上限是pow(2^64, 1/4) = 2^16 = 65536 对于底数base,指数的上限就是ceil(64*lo ...
- uva 11752 The Super Powers 素数+大数判断大小
题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_proble ...
- The Super Powers
The Super Powers Time Limit: 1000MS Memory Limit: Unknown 64bit IO Format: %lld & %llu [Subm ...
- UVA11752 The Super Powers
/* UVA11752 The Super Powers https://vjudge.net/contest/153365#problem/Y 数论 注意a^n=b要用除法求,并且求得的n比实际大1 ...
- UVA 11752 The Super Powers —— 数学与幂
题目链接:https://vjudge.net/problem/UVA-11752 题解: 1.首先变量必须用unsig long long定义. 2.可以分析得到,当指数为合数的时候,该值合法. 3 ...
- UVA 11752 The Super Powers【超级幂】
题目链接: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=111527#problem/Z 题意: 我们称一个可以由至少两个不同正整数的幂 ...
- uva 11752 The Super Powers (数论+枚举)
题意:找出1~2^64-1中 能写成至少两个数的幂形式的数,再按顺序输出 分析:只有幂是合数的数才是符合要求的.而幂不会超过64,预处理出64以内的合数. 因为最小的合数是4,所以枚举的上限是2的16 ...
随机推荐
- golang交叉编译:Linux - Windows
环境:Debian jessiego 1.7.4Windows 7 背景: 在debian中写好的程序编译后在windows上运行. 程序中使用了sqlite3 import( _ "git ...
- 林帆:Docker运行GUI软件的方法
继上周的“Kubernetes v1.0特性解析”分享之后,本周我们邀请到ThoughtWorks咨询师林帆为大家带来主题为“Docker运行GUI软件的方法”的分享. 嘉宾简介:林帆,Thought ...
- Segment Tree Beats 区间最值问题
Segment Tree Beats 区间最值问题 线段树一类特殊技巧! 引出:CF671C Ultimate Weirdness of an Array 其实是考试题,改题的时候并不会区间取最值,区 ...
- MS SQL Server字符拆分函数
Insus.NET以前有用XQuery的nodes()方法写过一个函数,是MS SQL字符拆分的函数,http://www.cnblogs.com/insus/archive/2012/02/26/2 ...
- 20155320《网络对抗》MSF基础应用
20155320<网络对抗>MSF基础应用 基础问题回答 用自己的话解释什么是exploit,payload,encode 于exploit,我觉得exploit是利用一些工具和方法,通过 ...
- 20155338《网络对抗》Web安全基础实践
20155338<网络对抗>Web安全基础实践 实验过程 WebGoat 在终端中输入 java -jar webgoat-container-7.0.1-war-exec.jar 开启W ...
- python 回溯法 子集树模板 系列 —— 8、图的遍历
问题 一个图: A --> B A --> C B --> C B --> D B --> E C --> A C --> D D --> C E -- ...
- SpringBoot中使用Quartz笔记
Quartz可以用来做什么? Quartz是一个任务调度框架,可用来做定时任务. 吧啦吧啦......... 还是直接上代码. application.properties 配置文件. * * ? ...
- stl源码剖析 详细学习笔记 set map
// // set map.cpp // 笔记 // // Created by fam on 15/3/23. // // //---------------------------15/03 ...
- 架构师修炼 III - 掌握设计原则
关于软件的设计原则有很多,对于设计原则的掌握.理解.实践及升华是架构师的一项极为之必要的修炼. 记得在12年前第一次阅读<敏捷开发>时,五大基本设计原则就深深地植入到我的脑海中一直影响至今 ...