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的解决办法) ...
随机推荐
- 20170623_oracle基础知识_常见问题
1 如何配置网络服务?两种连接 Oracle 工具? 1) 打开Net Manager 2) 选择服务命名,点击“+ ”号 3 ) 网络服务名: remote协议:tcp/ip 主机名:ip地址 端 ...
- 【Ubuntu】某灯图标过大
发现某灯在桌面上图标过大,点击resize拖动没反应,遂查找原因 发现是它图标只有128x128的版本,所以显得比别的图标大 打开lantern.desktop(不知道.desktop请看https: ...
- E - 吃糖
题目描述: 某人买了n兜糖果,第i兜有Ai块糖.此人把所有这些糖果用一个数字标记起来:他这样标记这些糖,第一袋糖用用数字1到A1,第二袋糖用数字A1+1到A1+A2,如此类推.如果还没明白看样例可以更 ...
- MVC web api 返回JSON的几种方式,Newtonsoft.Json序列化日期时间去T的几种方式。
原文链接:https://www.muhanxue.com/essays/2015/01/8623699.html MVC web api 返回JSON的几种方式 1.在WebApiConfig的Re ...
- Reward(toposort)
http://acm.hdu.edu.cn/showproblem.php?pid=2647 #include <stdio.h> #include <string.h> #i ...
- codevs3370 选学霸(背包dp,并查集)
3372 选学霸 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 大师 Master 题目描述 Description 老师想从N名学生中选M人当学霸,但有K对人实力相 ...
- 面试题:InnoDB中一棵B+树能存多少行数据?
阅读本文大概需要 5 分钟. 作者:李平 | 来源:个人博客 一.InnoDB 一棵 B+ 树可以存放多少行数据? InnoDB 一棵 B+ 树可以存放多少行数据? 这个问题的简单回答是:约 2 千万 ...
- 【USACO2002 Feb】奶牛自行车队
[USACO2002 Feb]奶牛自行车队 Time Limit: 1000 ms Memory Limit: 131072 KBytes Description N 头奶牛组队参加自行车赛.车队在比 ...
- [转]Linux定时任务Crontab详解
转自:http://blog.chinaunix.net/uid-7552018-id-182133.html 今天做了个数据库的备份脚本,顺便系统得学习一下Linux下定时执行脚本的设置.Linux ...
- js 计算时间差
function GetDateDiff(startDate,endDate) { var startTime = new (<any>Date)(Date.parse(startDate ...