Problem 56
Problem 56
https://projecteuler.net/problem=56
Powerful digit sum
A googol (10100) is a massive number: one followed by one-hundred zeros; 100100 is almost unimaginably large: one followed by two-hundred zeros. Despite their size, the sum of the digits in each number is only 1.
一个古戈尔(10100) 数虽然巨大无比,但是它的位数之和仅仅为1。
Considering natural numbers of the form, ab, where a, b < 100, what is the maximum digital sum?
考虑以下情况:
ab, a, b < 100,
最大的位数之和为多少?
from power import power maximum = 0
for a in range(1, 100):
for b in range(1, 100):
num = power(a, b)
digits = list(str(num))
digits_sum = 0
for i in digits:
digits_sum += int(i)
if digits_sum > maximum:
maximum = digits_sum
print(maximum)
# 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 56的更多相关文章
- 刘汝佳 算法竞赛-入门经典 第二部分 算法篇 第五章 3(Sorting/Searching)
第一题:340 - Master-Mind Hints UVA:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Item ...
- BestCoder Round #56 1002 Clarke and problem 1003 Clarke and puzzle (dp,二维bit或线段树)
今天第二次做BC,不习惯hdu的oj,CE过2次... 1002 Clarke and problem 和Codeforces Round #319 (Div. 2) B Modulo Sum思路差不 ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
- 覆盖问题:最大覆盖问题(Maximum Covering Location Problem,MCLP)和集覆盖问题(Location Set Covering Problem,LSCP)
集覆盖问题研究满足覆盖所有需求点顾客的前提下,服务站总的建站个数或建 设费用最小的问题.集覆盖问题最早是由 Roth和 Toregas等提出的,用于解决消防中心和救护车等的应急服务设施的选址问题,他们 ...
- nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 56; cvc-complex-type.2.4.c通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- 【HDU 5233】Tree chain problem (树形DP+树剖+线段树|树状数组)最大权不相交树链集
[题目] Tree chain problem Problem Description Coco has a tree, whose vertices are conveniently labeled ...
- 56个PHP开发常用代码
2016/02/14 6203 4 在编写代码的时候有个神奇的工具总是好的!下面这里收集了 50+ PHP 代码片段,可以帮助你开发 PHP 项目. 这些 PHP 片段对于 PHP 初学者也非常 ...
- BZOJ 3407: [Usaco2009 Oct]Bessie's Weight Problem 贝茜的体重问题( dp )
01背包... ----------------------------------------------------------------------- #include<cstdio&g ...
- Error 56: The Cisco Systems, Inc. VPN Service has not been started(Cisco VPN在Vista下出现Error 56的解决办法)
Error 56: The Cisco Systems, Inc. VPN Service has not been started(Cisco VPN在Vista下出现Error 56的解决办法) ...
随机推荐
- BNU 13064 Dice (I) 前缀和优化DP
Dice (I) You have N dices; each of them has K faces numbered from 1 to K. Now you have arranged th ...
- (C语言版)链表(三)——实现双向链表创建、删除、插入、释放内存等简单操作
上午写了下单向循环链表的程序,今天下午我把双向链表的程序写完了.其实双向链表和单向链表也是有很多相似的地方的,听名字可以猜到,每个节点都包含两个指针,一个指针指向上一个节点,一个指针指向下一个节点.这 ...
- YOCTO
Yocto ,是一个开源社区它通过提供模版.工具和方法帮助开发者创建基于linux内核的定制系统,支持ARM, PPC, MIPS, x86 (32 & 64 bit)硬件体系架构.
- 【Codeforces 670C】 Cinema
[题目链接] http://codeforces.com/contest/670/problem/C [算法] 离散化 [代码] #include<bits/stdc++.h> using ...
- PCB 所建不凡 AWS 技术峰会2018 • 深圳站 2018.9.20
在去[AWS 技术峰会2018 • 深圳站]之提前并没有AWS提前做功课,主要PCB这行业基本自己搭服务器搭应用,不会买云服务器.由于没用过企业级的云服务器,对云这方面还是了解还是非常有限的. 市面上 ...
- javascript的鼠标事件---基础
- 【转】 [MySQL 查询语句]——分组查询group by
group by (1) group by的含义:将查询结果按照1个或多个字段进行分组,字段值相同的为一组(2) group by可用于单个字段分组,也可用于多个字段分组 select * from ...
- go 简单路由实现
一.golang 路由实现的简单思路 1.http启动后,请求路径时走统一的入口函数 1.通过统一函数入口,获取request 的url路径 2.通过对url的路径分析,确定具体执行什么函数 二.统一 ...
- NOIP真题汇总
想想在NOIP前总得做做真题吧,于是长达一个月的刷题开始了 涉及2008-2016年大部分题目 NOIP [2008] 4/4 1.传纸条:清真的三维DP 2.笨小猴:字符串模拟 3.火柴棒等式:打表 ...
- ACM_3n+1问题(克拉兹问题+线段树区间查询最大值)
3n+1问题 Time Limit: 2000/1000ms (Java/Others) Problem Description: 考虑如下的序列生成算法:从整数n开始,如果n是偶数,把它除以2:如果 ...