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

  1. (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 ...

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

  3. LeetCode All in One 题目讲解汇总(持续更新中...)

    终于将LeetCode的免费题刷完了,真是漫长的第一遍啊,估计很多题都忘的差不多了,这次开个题目汇总贴,并附上每道题目的解题连接,方便之后查阅吧~ 477 Total Hamming Distance ...

  4. Common Bugs in C Programming

    There are some Common Bugs in C Programming. Most of the contents are directly from or modified from ...

  5. You Can Do Research Too

    You Can Do Research Too I was recently discussing gatekeeping and the process of getting started in ...

  6. Win32_Battery class

    wmi的Win32_Battery类实现 其中EstimatedChargeRemaining属性返回剩余电量的百分比,EstimatedRunTime属性返回剩余时间(分钟) 其他属性参考http: ...

  7. COMBINATORIAL TESTING

    COMBINATORIAL TESTING -Test note of “Essential Software Test Design” 2015-09-06 Content 16.1 Coverag ...

  8. CodeForce:16C-Monitor

    传送门:http://codeforces.com/problemset/problem/16/C Monitor time limit per test0.5 second memory limit ...

  9. F题

    Problem F Codeforces 16E 这道题是一道数位Dp将鱼的死活列为0两种状态然后找DP关系 •题意:有n(n<=18)条鱼,接下来的n-1天,每天会有一对鱼(a,b)相遇,每天 ...

随机推荐

  1. iOS7系统iLEX RAT冬青鼠安装教程:无需刷机还原纯净越狱系统

    全网科技 温馨提醒:iLEX RAT和Semi-Restore的作用都是让你的已越狱的设备恢复至越狱的初始状态. 可是要注意无论你是用iLexRAT冬青鼠还是Semi-restore.对于还原来说都存 ...

  2. oc49--@class

    // Person.h #import <Foundation/Foundation.h> @class Car; //#import "Car.h" // 由于imp ...

  3. React Native - 认识与环境搭建

    01 传统开发的痛点 1.人员稀缺 2.开发成本高 3.代码复用率低 4.无法动态更新 02 React Native的优点 1.跨平台 2.性能高 3.低投入 4.支持动态更新 03 开发环境搭建 ...

  4. 讲一讲WiFi快连、SmartConfig、SmartConnect

    最近要给公司同事们培训WiFi快连技术,整理了相关资料,也分享在博客这,献给有缘人. 前言 现在的智能硬件产品,以WiFi品类居多,这些WiFi硬件没有人机交互界面,但设备要上网肯定要配置SSID等相 ...

  5. C++中的inline的用法

    C++中的inline的用法  参考:http://www.cnblogs.com/fnlingnzb-learner/p/6423917.html 1. 引入inline关键字的原因 在c/c++中 ...

  6. poi读取word2003(.doc文档)中的表格

    poi读取word2003(.doc文档)中的表格 Jakarta POI 是apache的子项目,目标是处理ole2对象.它提供了一组操纵Windows文档的Java API.在网上见到好多通过po ...

  7. 将tflearn的模型保存为pb,给TensorFlow使用

    参考:https://github.com/tflearn/tflearn/issues/964 解决方法: """ Tensorflow graph freezer C ...

  8. [NOIP 2016] 蚯蚓

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4721 [算法] 首先,我们可以维护一个堆,堆中存放蚯蚓的长度,由于除当前蚯蚓其他的蚯 ...

  9. B1085 [SCOI2005]骑士精神 A*搜索

    其实就是一个爆搜加剪枝.直接爆搜肯定不行,而A*算法则是想假如剩下都是最优的话,我当前步数还是不足以达到这个状态,那么就直接返回,因为最优状态也无法做到显然不行. 这道题可以用A*最主要就是因为有15 ...

  10. bzoj 1050 [ HAOI 2006 ] 旅行comf —— 并查集

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1050 没思路的话想想暴力就好了... 首先,比值最小就是确定最小值后最大值最小: 怎样确定最 ...