TOJ1502Find All M^N Please
来源:互联网 发布:node sass windows 编辑:程序博客网 时间:2024/06/08 13:42
Find All M^N Please
Time Limit(Common/Java):1000MS/10000MS Memory Limit:65536KByte
Total Submit: 37 Accepted: 15
Total Submit: 37 Accepted: 15
Description
Recently, Joey has special interest in the positive numbers that could be represented as M ^ N (M to the power N), where M and Nare both positive integers greater than or equal to 2. For example, 4, 8, 9 and 16 are first four such numbers, as 4 = 2 ^ 2, 8 = 2 ^ 3, 9 = 3 ^ 2, 16 = 2 ^ 4. You are planning to give Joey a surprise by giving him all such numbers less than 2 ^ 31 (2147483648). List them in ascending order, one per line.
Input
Output
Output all M^N numbers as shown in the output samples.
Sample Input
Sample Output
48916252732|| <-- a lot more numbers|102410891156122512961331|||
#include <cstdio>#include <cstring>#include <cmath>#include <algorithm>#define MAX 50000using namespace std;double INF = 2147483648.0;int v[MAX];int main(){ int i, j, k = 0; memset(v, 0, sizeof(v)); for (i = 2; i <= (int)sqrt(INF); i++ ) { for ( j = 2; j <= (int)(log(INF) / log(i)); j++ ) { v[k++] = (int)(pow(1.0*i, 1.0*j) + 0.5); //v[k++] = (int)(pow(1.0*i, 1.0*j) );!!!精度. } } sort(v, v+k); for ( i = 1; i < k; i++ ) { if ( v[i] != v[i-1] ) { printf("%d\n", v[i]); } } return 0;}
- TOJ1502Find All M^N Please
- zoj 2952 Find All M^N Please
- zoj Find All M^N Please
- zoj 2952 Find All M^N Please
- ZOJ 2952 Find All M^N Please
- ZOJ 2952 Find All M^N Please(数学啊 )
- ZOJ 2679 Old Bill ||ZOJ 2952 Find All M^N Please 两题水题
- ZOJ.2952 Find All M^N Please【数学】 2015/10/20
- Hi, All, Please Enjoy Here.
- Select n numbers from 1 to m with all of array 'all' and none of array 'none'
- set all bits between i and j in N equal to M
- [CrackCode] 5.1 Set all bits between i and j in N equal to M
- 输出n-m-n
- Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral or
- i'm all geared up
- poj 1036 n!/(n-m)!*m!
- m选n算法
- M选N
- linux(版本是红帽企业版5)下安装ns2(版本是ns-allinone-2.35)
- L0处理开始 matlab知识 最简单的小函数
- UNIX网络编程---守护进程和inetd超级服务器(十三)
- 1018 Communication System
- 通知:精彩文章尽在http://www.cnblogs.com/Romi,欢迎访问
- TOJ1502Find All M^N Please
- 复制文件/文件夹时保留原始创建时间
- EhLib表格控件DBGridEh自动排序、自动过滤的实现
- HDU 4714
- MACHINE_START分析
- 九度1012畅通工程
- 不用变量交换两个int变量的值的分析
- 最新发布EhLib 6.2中的新功能DropDownForms的应用
- java练习题