UVA - 11752 The Super Powers
来源:互联网 发布:猴王水果竞猜源码php 编辑:程序博客网 时间:2024/05/16 19:16
We all know the Super Powers ofthis world and how they manage to get advantages in political warfare or evenin other sectors. But this is not a political platform and so we will talkabout a different kind of super powers – “The Super Power Numbers”. A positivenumber is said to be super power when it is the power of at least two differentpositive 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 noinput.
Output
Print all theSuper Power Numbers within 1 and 2^64 -1. Each line contains a single superpower 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
.
.
.
ProblemSetter: Shahriar Manzoor, Special Thanks: Sohel Hafiz
题意:如果一个数是超级幂的话,那么它至少是两个不同正整数的幂,从小到大输出所有
思路:如果这个数是超级幂的话,那么它的指数一定是合数,如果我们先枚举底数,大小为1~(1<<16),然后在2^64-1的范围内找数
#include <iostream>#include <cstring>#include <algorithm>#include <set>#include <cstdio>#include <cmath>typedef unsigned long long ll;using namespace std;const int maxn = 100;int vis[maxn];int main() {memset(vis, 0, sizeof(vis));for (int i = 2; i < 100; i++)if (!vis[i]) {for (int j = i*i; j < 100; j += i)vis[j] = 1;}set<ll> ans;for (ll i = 2; i < (1<<16); i++) {int top = ceil(64*log10(2)/log10(i));ll tmp = 1;for (int j = 1; j < top; j++) {tmp *= i;if (vis[j])ans.insert(tmp);}}printf("1\n");set<ll>::iterator ite = ans.begin();while (ite != ans.end()) cout << *ite++ << endl;return 0;}
- 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 (数论)
- 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【超级幂】
- 职场分享:如何在工作中提高关注度
- POJ-2987-Firing
- 网路搜集:java整型数与网络字节序的 byte[] 数组转换关系
- 谈谈未来 APP 产品设计的革命性趋势
- 网络通信框架Volley使用详细说明
- UVA - 11752 The Super Powers
- VC++动态链接库(DLL)编程深入浅出
- Spring-boot的控制器实现
- java从头学04-2[数组应用]
- maven 安装 与Eclipse下 配置
- Oracle 11g RAC 11.2.0.3数据库升级失败后的两种回退方法
- 过多if-else分支的优化
- GET与POST方法的区别
- LeetCode | Merge Two Sorted Lists(合并两个链表)