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. GDUT Krito的讨伐(bfs&amp;&amp;优先队列)

    题意 Description Krito最终干掉了99层的boss,来到了第100层. 第100层能够表示成一颗树.这棵树有n个节点(编号从0到n-1),树上每个节点可能有非常多仅仅怪物. Krito ...

  2. 第十七周自由练习项目——acm 学生最高最低成绩

    /* *程序的版权和版本号声明部分: *Copyright(c)2014,烟台大学计算机学院学生 *All rights reserved. *文件名:acm 学生最高与最低成绩 *作者:刘中林 *完 ...

  3. 学习笔记——WCF

    学了一下WCF,发现怎么跟Web Service这么像! 这个WCF究竟干嘛的? 一查,原来: "Windows Communication Foundation (WCF) 是由微软发展的 ...

  4. Linux批量生成生成帐户脚本,随机密码

    此脚本应用于生产环境下生成帐户,也可生成成百上千个密码相同的帐户.脚本代码如下: 批量生成: #!/bin/bash for name in tom jerry joe jane do useradd ...

  5. 复习--最小生成树&&并查集

    我个人比较喜欢Kruskal算法,所以就把这个方法写了一下,但过不了洛谷,70分. 思路是先全读入,再排序,一条一条加边.运用并查集. #include<iostream> #includ ...

  6. Anagram Groups(字符串)

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2316 理解错一点题意就能WA到死...题中对于 ...

  7. Stockbroker Grapevine(floyd)

    http://poj.org/problem?id=1125 题意: 首先,题目可能有多组测试数据,每个测试数据的第一行为经纪人数量N(当N=0时, 输入数据结束),然后接下来N行描述第i(1< ...

  8. selenium3 + python - js处理readonly属性

    前言 日历控件是web网站上经常会遇到的一个场景,有些输入框是可以直接输入日期的,有些不能,以我们经常抢票的12306网站为例,详细讲解如何解决日历控件为readonly属性的问题. 基本思路:先用j ...

  9. Django day06 模版层(二) 过滤器 标签

    一: 模板语言之过滤器: " | " 前后的区分: 前面的是函数的第一个参数, 后面的是python的一个函数, 冒号后面的是第二个参数例:  <p>过滤器之默认值:{ ...

  10. layui富文本编译器添加图片

    1.创建富文本编辑器 <form class="layui-form" method="post" id="myForm" encty ...