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 ...
随机推荐
- 609E- Minimum spanning tree for each edge
Connected undirected weighted graph without self-loops and multiple edges is given. Graph contains n ...
- day51
JS基础操作 一.分支结构 1.if语句 if 基础语法 if (条件表达式) { 代码块; } // 当条件表达式结果为true,会执行代码块:反之不执行 // 条件表达式可以为普通表达式 // 0 ...
- VS 代码段
系统默认代码段 代码段名 描 述 #if 该代码段用#if和#endif命令围绕代码 #region 该代码段用#region和#endregion命令围绕代码 ~ 该代码段插入一个析构函数 a ...
- odoo之可选择多个内容显示问题
<field name="partner_id" widget="many2many_tags" options="{'no_create': ...
- 网络对抗技术 2017-2018-2 20155215 Exp9 Web安全基础
1.实践过程 前期准备:WebGoat WebGoat分为简单版和开发板,简单版是个Java的Jar包,只需要有Java环境即可,我们在命令行里执行java -jar webgoat-containe ...
- 20155237 第十一周java课堂程序
20155237 第十一周java课堂程序 内容一:后缀表达式 abcde/-f+ 内容二:实现Linux下dc的功能,计算后缀表达式的值 填充下列代码: import java.util.Scann ...
- MSBUILD : error MSB3428: 未能加载 Visual C++ 组件“VCBuild.exe”
问题 MSBUILD : error MSB3428: 未能加载 Visual C++ 组件"VCBuild.exe".要解决此问题,1) 安装 .NET Framework 2. ...
- flask_admin 笔记四 自定义视图
定义自己的视图 对于您的要求非常具体的情况,您很难用内置的ModelView类来满足这些需求,Flask-Admin使您可以轻松地完全控制并将自己的视图添加到界面中. 1)独立视图 可以通过扩展Bas ...
- numpy 初识(二)
针对 numpy.array(序列)的实例介绍 ndim 数组(矩阵)的维度 size 所有元素的和 数学运算(+, -) 元素个数一样,对应位置相减 加,减,乘,平方一个数,执行广播形式:即都减去一 ...
- hexo发文章
http://blog.csdn.net/qq_36099238/article/details/54576089