UVa 11752 The Super Powers (数学)
来源:互联网 发布:特朗普段子知乎 编辑:程序博客网 时间:2024/05/29 18:14
11752 - The Super Powers
Time limit: 1.000 seconds
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=467&page=show_problem&problem=2852
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
.
.
.
用set实现,也可以用数组和sort&unique实现(更快)
完整代码:
/*0.036s*/#include<cstdio>#include<cmath>#include<set>#define LL unsigned long longusing namespace std;const int index[100] ={4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20, 21, 22, 24, 25, 26,27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46,48, 49, 50, 51, 52, 54, 55, 56, 57, 58, 60, 62, 63, 64 /// 多算一个};///合数表set<LL> ans;int main(void){LL i, maxi = 1 << 16; /// 底数的上限int j, maxindex; /// 指数的上限LL cur;ans.insert(1);for (i = 2; i < maxi; i++){cur = i * i; /// i用LL类型的原因cur *= cur;ans.insert(cur);maxindex = ceil(64 * log(2) / log(i)) - 1; /// 指数的上限for (j = 1; index[j] <= maxindex; ++j){cur *= (index[j] - index[j - 1] == 1 ? i : i * i);ans.insert(cur);}}for (set<LL>::iterator iter = ans.begin(); iter != ans.end(); ++iter)printf("%llu\n", *iter);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 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 超级幂
- CEdit小结
- 减少oracle sql回表次数 提高SQL查询性能
- android异步网络连接开源:Android Asynchronous Http Client
- webgrind安装使用详细说明
- 新浪微博布局学习——活用RelativeLayout
- UVa 11752 The Super Powers (数学)
- CString常用方法简介
- 第三十三篇·构建个人的服务器
- [每日一题] 11gOCP 1z0-052 :2013-09-8 用户管理下的热备报错:ORA-01123.................................A45
- Android图像开源视图:SmartImageView
- Java内存泄露
- 默写js日历控件和详细注释(非原创 原作者:@author KimSoft (jinqinghua [at] gmail.com)
- Ubuntu下安装Bochs各种奇怪错误汇总
- 分享功能实现