Problem 16
Problem 16
pow(2, 15) = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
2的15次方等于32768,而这些数字(3+2+7+6+8)的和为26
What is the sum of the digits of the number pow(2, 1000)?
2的1000次方的位数之和为多少?
import math power = math.pow(2, 1000)
sum_of_digits = 0
with open('power_of_two.txt', 'w') as f:
print('%d' % power, file=f)
with open('power_of_two.txt') as f:
for line in f:
for c in line:
try:
sum_of_digits += int(c)
except:
pass print(sum_of_digits)
Problem 16的更多相关文章
- (Problem 16)Power digit sum
215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of th ...
- (Problem 17)Number letter counts
If the numbers 1 to 5 are written out in words: one, two, three, four, five, then there are 3 + 3 + ...
- LeetCode All in One 题目讲解汇总(持续更新中...)
终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...
- Common Bugs in C Programming
There are some Common Bugs in C Programming. Most of the contents are directly from or modified from ...
- You Can Do Research Too
You Can Do Research Too I was recently discussing gatekeeping and the process of getting started in ...
- Win32_Battery class
wmi的Win32_Battery类实现 其中EstimatedChargeRemaining属性返回剩余电量的百分比,EstimatedRunTime属性返回剩余时间(分钟) 其他属性参考http: ...
- COMBINATORIAL TESTING
COMBINATORIAL TESTING -Test note of “Essential Software Test Design” 2015-09-06 Content 16.1 Coverag ...
- CodeForce:16C-Monitor
传送门:http://codeforces.com/problemset/problem/16/C Monitor time limit per test0.5 second memory limit ...
- F题
Problem F Codeforces 16E 这道题是一道数位Dp将鱼的死活列为0两种状态然后找DP关系 •题意:有n(n<=18)条鱼,接下来的n-1天,每天会有一对鱼(a,b)相遇,每天 ...
随机推荐
- Codesys——常用快捷键列表
F1——打开Help文档: F2——打开Input Assistant: F5——执行程序(Start): F9——添加或取消断点(Toggle Breakpoint): F8——单步进入(Step ...
- hdoj--1220--Cube(数学推导)
Cube Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submi ...
- 76.培训记录信息 Extjs 页面
1.培训记录信息页面jsp <%@ page language="java" import="java.util.*" pageEncoding=&quo ...
- go之for循环
一.基于计数器的迭代 格式 for 初始化语句; 条件语句; 修饰语句{} 实例 package main import "fmt" func main(){ for i:=0;i ...
- B - Is your horseshoe on the other hoof?
Problem description Valera the Horse is going to the party with friends. He has been following the f ...
- 树莓派-基于raspivid实现拍视频
经过上一篇<<树莓派-安装摄像头模块>>之后 想要用摄像头模块拍一段视频的话,可以从命令行运行 raspivid 工具.下面这句命令会按照默认配置(长度5秒,分辨率1920x1 ...
- C#微信公众号的开发——服务配置
最近因为需要用C#开发微信公众号的一些功能,记录一下开发公众号的一些坑..... 首先先介绍一下,微信公众号的官方文档.虽然这个文档我感觉比较糙,但是还是可以借鉴一下让我们摸着石头过河的. 首先我们得 ...
- HTTPS 为什么更安全,先看这些
HTTPS 是建立在密码学基础之上的一种安全通信协议,严格来说是基于 HTTP 协议和 SSL/TLS 的组合.理解 HTTPS 之前有必要弄清楚一些密码学的相关基础概念,比如:明文.密文.密码.密钥 ...
- HTTPS的中那些加密算法
密码学在计算机科学中使用非常广泛,HTTPS就是建立在密码学基础之上的一种安全的通信协议.HTTPS早在1994年由网景公司首次提出,而如今在众多互联网厂商的推广之下HTTPS已经被广泛使用在各种大小 ...
- P2241 统计方形(数据加强版)
题目背景 1997年普及组第一题 题目描述 有一个n*m方格的棋盘,求其方格包含多少正方形.长方形 输入输出格式 输入格式: n,m因为原来数据太弱,现规定m小于等于5000,n小于等于5000(原来 ...