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的更多相关文章

  1. Project Euler problem 63

    这题略水啊 首先观察一下. 10 ^ x次方肯定是x + 1位的 所以底数肯定小于10的 那么我们就枚举1~9为底数 然后枚举幂级数就行了,直至不满足题目中的条件即可break cnt = 0 for ...

  2. 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 ...

  3. 入门经典——基础数据结构专题(List)

    UVA127 链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_pr ...

  4. 密码学笔记-一段base64wp

    CTF--练习平台 例题: 一段Base64 flag格式:flag{xxxxxxxxxxxxx} 附件: base64.txt 1.base64解码:http://base64.xpcha.com/ ...

  5. [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 ...

  6. PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案

    $s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...

  7. How to address this problem?

    root# cmake .. No problem. root# make [ 63%] Linking CXX shared module collisionperceptor.so/usr/bin ...

  8. 2016年湖南省第十二届大学生计算机程序设计竞赛Problem A 2016 找规律归类

    Problem A: 2016 Time Limit: 5 Sec  Memory Limit: 128 MB Description  给出正整数 n 和 m,统计满足以下条件的正整数对 (a,b) ...

  9. HDU 4910 Problem about GCD 找规律+大素数判断+分解因子

    Problem about GCD Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others ...

随机推荐

  1. 【转】Android进阶2之 阴影制作(Shadow)

    阴影制作:包括各种形状(矩形,圆形等等),以及文字等等都能设置阴影. 阴影制作是什么原理呢? 其实很简单,你需要设置阴影的东西被看作一个主层.然后在主层下面画一个阴影层. 阴影制作涉及到一个重要函数: ...

  2. 【Codeforces 429D】 Tricky Function

    [题目链接] http://codeforces.com/problemset/problem/429/D [算法] 令Si = A1 + A2 + ... + Ai(A的前缀和) 则g(i,j) = ...

  3. [置顶] Snow的追寻

    题目描述 Snow终于得知母亲是谁,他现在要出发寻找母亲. 王国中的路由于某种特殊原因,成为了一棵有n个节点的根节点为1的树,但由于"Birds are everywhere.", ...

  4. Windows7安装SQLServer 2008图解

    Windows7安装SQL Server 2008图解        这几天因为需要,一直想安装SQL Server 2008来作为Web后台的数据库进行些实验,但总是没有时间,今天终于有时间了,便安 ...

  5. jQuery Validate插件实现表单强大的验证功能

    转自:http://www.jb51.net/article/76595.htm jQuery Validate插件捆绑了一套有用的验证方法,包括 URL 和电子邮件验证,同时提供了一个用来编写用户自 ...

  6. 【转】pycharm常用快捷键

    转自:http://www.2cto.com/os/201410/341542.html 转来珍藏着,以后慢慢完善. 编辑类: Ctrl + Space 基本的代码完成(类.方法.属性)Ctrl + ...

  7. HTTP Status 500 - Could not write content: could not initialize proxy - no Session

    分析出现no Session错误的原因以及给出解决方案: 使用SpringMVC + JSON数据返回时,经常会出现no Session的错误: 报错原因:因为懒加载在提取关联对象的属性值的时候发现E ...

  8. day03_12/13/2016_bean属性的设置之构造器方式注入

  9. Zookeeper概念学习系列之zookeeper的角色

    详细,见如下图 1.领导者(leader) : 负责进行投票的发起和决议,更新系统状态. 2.学习者(learner): 包括跟随者(follower)和观察者(observer). 跟随者(foll ...

  10. SQL Server之纵表与横表互转

    1,纵表转横表 纵表结构 Table_A: 转换后的结构: 纵表转横表的SQL示例: SELECT  Name ,        SUM(CASE WHEN Course = N'语文' THEN G ...