博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
zoj 2952 Find All M^N Please 暴力
阅读量:3905 次
发布时间:2019-05-23

本文共 903 字,大约阅读时间需要 3 分钟。

题目:

Recently, Joey has special interest in the positive numbers that could be represented as M ^ N (M to the power N), where M and N are 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.

Sample Output

 

48916252732|| <-- a lot more numbers|102410891156122512961331|||

思路:

因为底数最大不超过1e5,所以只需要暴力枚举,用个vector保存结果,排个序输出即可。

代码如下:

#include 
#include
#include
#include
#include
using namespace std;typedef long long ll;const int maxn=1e5+5;int m,n;int vis[maxn];vector
v;int main(){ memset (vis,0,sizeof(vis)); for (int i=2;i
=2147483648) break; if(!vis[i]) { for (ll j=i*i;j<2147483648;j*=i) { if(j

 

转载地址:http://nkoen.baihongyu.com/

你可能感兴趣的文章
HDU 2456 饭卡 (01背包)
查看>>
HDU 1559 最大子矩阵
查看>>
Open Judge 4010 :2011
查看>>
百练OJ-2815 城堡问题【DFS】
查看>>
CODE[VS] 1025 选菜 【背包】
查看>>
POJ 1724 ROADS【DFS+剪枝】
查看>>
AOJ 847 整数拆段
查看>>
AOJ 848 分数拆分
查看>>
UVA 133 The Dole Queue 【约瑟夫环】
查看>>
XDOJ 1208 B.笑爷买房 【DFS】
查看>>
部门年度工作总结的内容
查看>>
pandas学习笔记
查看>>
Numpy笔记
查看>>
正则表达式
查看>>
python线程进程笔记
查看>>
TensorFlow初学者必须了解的55个经典案例
查看>>
机器学习笔记
查看>>
数十种TensorFlow实现案例汇集:代码+笔记
查看>>
python记录的错误与知识
查看>>
内核中各种套接字的关系
查看>>