Problem 63
Problem 63
https://projecteuler.net/problem=63
Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is a ninth power.
五位数16807同时是7的五次方,同样地,九位数134217728是8的九次方。
How many n-digit positive integers exist which are also an nth power?
有多少个n位数正整数,这些正整数同时是某个数字的n次方?
from power import power count = 0
for i in range(1, 100):
for p in range(1, 100):
num = power(i, p)
if len(str(num)) == p:
print(i, p, num)
count += 1
print(count)
# power.py
def power(x, y):
if y == 1:
return x
tot = 1
for i in range(y):
tot *= x
return tot if __name__ == '__main__':
for x in range(1, 5):
for y in range(1, 5):
print('power({0}, {1}) = {2}'.format(x, y, power(x, y)))
Problem 63的更多相关文章
- Project Euler problem 63
这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...
- Project Euler:Problem 63 Powerful digit counts
The 5-digit number, 16807=75, is also a fifth power. Similarly, the 9-digit number, 134217728=89, is ...
- 入门经典——基础数据结构专题(List)
UVA127 链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...
- 密码学笔记-一段base64wp
CTF--练习平台 例题: 一段Base64 flag格式:flag{xxxxxxxxxxxxx} 附件: base64.txt 1.base64解码:http://base64.xpcha.com/ ...
- [RHEL8]安装Docker Problem: package docker-ce-3:19.03.6-3.el7.x86_64 requires containerd.io
系统环境 # cat /etc/redhat-release Red Hat Enterprise Linux release 8.0 (Ootpa) 安装依赖 # yum install -y yu ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
- How to address this problem?
root# cmake .. No problem. root# make [ 63%] Linking CXX shared module collisionperceptor.so/usr/bin ...
- 2016年湖南省第十二届大学生计算机程序设计竞赛Problem A 2016 找规律归类
Problem A: 2016 Time Limit: 5 Sec Memory Limit: 128 MB Description 给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) ...
- HDU 4910 Problem about GCD 找规律+大素数判断+分解因子
Problem about GCD Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others ...
随机推荐
- 【Codeforces】 Round #374 (Div. 2)
Position:http://codeforces.com/contest/721 我的情况 开始还是rank1,秒出C.(11:00机房都走光了,我ma到11:05才走,只打了一个小时) 结果.. ...
- bzoj 3944 Sum —— 杜教筛
题目:https://www.lydsy.com/JudgeOnline/problem.php?id=3944 杜教筛入门题! 看博客:https://www.cnblogs.com/zjp-sha ...
- CF949 C Data Center Maintenance——边双连通分量
题目:http://codeforces.com/contest/949/problem/C 把一个点指向修改它会影响到的点就可以做了: 有取模,所以多出一些要注意的地方,首先是可能出现环,所以需要 ...
- js产生随机数教程
<script> function GetRandomNum(Min,Max){ var Range = Max - Min; var Rand = Math.random() ...
- MyBatis 配置控制台上显示sql语句(log4j.properties 之三)
### direct log messages to stdout ###log4j.appender.stdout=org.apache.log4j.ConsoleAppenderlog4j.app ...
- CF126B Password
思路: kmp略作修改. 实现: #include <iostream> #include <cstdio> using namespace std; ; int neXt[M ...
- 图解TCP/IP笔记(3)——IP协议
目录 IP协议 IP寻址 IP地址组成 IP地址分类 广播地址 子网掩码 全局地址和私有地址 IP协议 跨越不同数据链路,实现两端节点之间的数据包传输 数据链路:只负责某一个区间之间的通信传输 IP协 ...
- IE9的F12工具,"网络"页签,点击"开始捕获"之后,请求显示的状态是"挂起"的分析和解决
最近一个项目,客户端使用用jQuery编写ajax请求,服务端采用struts2框架.js发送请求和action处理请求过程中,遇到一个问题.刚开始觉得问题很诡异,仔细定位很久之后才发现问题,虽然问题 ...
- html——标签选择器
交集选择器:标签+类(ID)选择器{属性:值:}.即要满足使用了某个标签,还要满足使用了类(id)选择器. <!DOCTYPE html> <html> <head> ...
- python中struct.pack()函数和struct.unpack()函数
python中的struct主要是用来处理C结构数据的,读入时先转换为Python的字符串类型,然后再转换为Python的结构化类型,比如元组(tuple)啥的~.一般输入的渠道来源于文件或者网络的二 ...