UVa 11752 - The Super Powers (数论)
来源:互联网 发布:幽浮2优化 编辑:程序博客网 时间:2024/04/30 02:33
A
The Super Powers
We all know the Super Powers of this world and how they manage to get advantages in political warfare or even in other sectors. But this is not a political platform and so we will talk about a different kind of super powers – “The Super Power Numbers”. A positive number is said to be super power when it is the power of at least two different positive integers. For example 64 is a super power as 64 = 82 and 64 = 43. You have to write a program that lists all super powers within 1 and 264 -1 (inclusive).
Input
This program has no input.
Output
Print all the Super Power Numbers within 1 and 2^64 -1. Each line contains a single super power number and the numbers are printed in ascending order.
Sample Input
Partial Judge Output
No input for this problem
1
16
64
81
256
512
.
.
.
Problem Setter: Shahriar Manzoor, Special Thanks: Sohel Hafiz
题意:
如果一个数至少是两个不同的正整数的幂,那么它称为超级幂。找出1-2^64-1之间的所有超级幂。
对于x^y 如果y是合数,那么x^y一定是超级幂
然后就是枚举底数和指数即可
#include <cstdio>#include <iostream>#include <vector>#include <algorithm>#include <cstring>#include <string>#include <map>#include <cmath>#include <queue>#include <set>using namespace std;//#define WIN#ifdef WINtypedef __int64 LL;#define iform "%I64d"#define oform "%I64d\n"#define oform1 "%I64d"#elsetypedef long long LL;#define iform "%lld"#define oform "%lld\n"#define oform1 "%lld"#endif#define S64I(a) scanf(iform, &(a))#define P64I(a) printf(oform, (a))#define P64I1(a) printf(oform1, (a))#define REP(i, n) for(int (i)=0; (i)<n; (i)++)#define REP1(i, n) for(int (i)=1; (i)<=(n); (i)++)#define FOR(i, s, t) for(int (i)=(s); (i)<=(t); (i)++)const int INF = 0x3f3f3f3f;const double eps = 10e-9;const double PI = (4.0*atan(1.0));typedef unsigned long long ULL;int vis[100];int heshu[100];int sieve(int n) { int m = (int) sqrt(n+0.5); memset(vis, 0, sizeof(vis)); for(int i=2; i<=m; i++) if(!vis[i]) { for(int j=i*i; j<=n; j+=i) { vis[j] = 1; } } int c = 0; for(int i=4; i<=n; i++) if(vis[i]) heshu[c++] = i; return c;}int main() { int heshuNum = sieve(64); int maxa = 1<<16; set<ULL> ans; ans.insert(1); for(int i=2; i<maxa; i++) { int top = ceil(64*log10(2)/log10(i)); ULL t = 1; for(int j=1; j<top; j++) { t *= i; if(vis[j]) ans.insert(t); } } set<ULL>::iterator it = ans.begin(); while(it != ans.end()) { cout<<*it++<<endl; } return 0;}
- UVA 11752 - The Super Powers (数论)
- UVa 11752 - The Super Powers (数论)
- uva 11752 -The Super Powers (数论)
- uva 11752 - The Super Powers(数论+枚举技巧)
- 【数论 && 找规律】UVA 11752 The Super Powers
- UVA - 11752 The Super Powers
- UVA 11752-The Super Powers
- Uva 11752 The Super Powers
- UVA 11752 The Super Powers
- uva 11752The Super Powers
- UVA 11752 The Super Powers
- uva 11752 The Super Powers
- UVA 11752 The Super Powers
- The Super Powers UVA
- The Super Powers UVA
- The Super Powers UVA
- Uva 11752 The Super Powers 解题报告(数学)
- UVA 11752 The Super Powers (集合打表)
- 找出二叉树中和为某一定值的所有路径
- docker学习 主流的pass平台(体验的是设计模式)
- @Override错误
- VS 自带打包程序
- CentOS上编译安装OpenCV-2.3.1与ffmpeg-2.1.2
- UVa 11752 - The Super Powers (数论)
- Developing IOS 7 Apps for iPhone and iPad (Lecture 10)
- 最大乘积(Maximum Product,UVA 11059)
- java制作五子棋和象棋之二象棋图形界面的设计
- 搞定LIBTOOL is undefined问题有方法可用[转载]
- NIO框架之MINA源码解析(二):mina核心引擎
- Android开发之详解五大布局
- fragment 生命周期
- NIO组件Selector工作机制详解(上)