(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 the number 21000?
题目大意:
题目大意:
215 = 32768 并且其各位之和为 is 3 + 2 + 7 + 6 + 8 = 26.
21000 的各位数之和是多少?
// (Problem 16)Power digit sum
// Completed on Sun, 17 Nov 2013, 15:23
// Language: C
//
// 版权所有(C)acutus (mail: acutus@126.com)
// 博客地址:http://www.cnblogs.com/acutus/
#include <stdio.h>
#include <stdbool.h> void solve(void)
{
int a[] = {};
int n, sum, i, j;
n = sum = ;
a[] = ;
for(i = ; i < ; i++) { //以1000进制的方法存储
for(j = ; j <= n; j++) {
a[j] *= ;
}
for(j = ; j <= n; j++) {
if(a[j] >= ) {
a[j] %= ;
a[j+]++;
n++;
}
}
}
for(i = ; i <= n; i++) {
sum += a[i] / ;
a[i] %= ;
sum += a[i] / ;
a[i] %= ;
sum += a[i] / ;
a[i] %= ;
sum += a[i] / ;
a[i] %= ;
sum += a[i]; }
printf("%d\n",sum);
} int main(void)
{
solve();
return ;
}
Answer:
|
1366 |
(Problem 16)Power digit sum的更多相关文章
- project euler 16:Power digit sum
>>> sum([int(i) for i in str(2**1000)]) 1366 >>>
- (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 + ...
- (Problem 34)Digit factorials
145 is a curious number, as 1! + 4! + 5! = 1 + 24 + 120 = 145. Find the sum of all numbers which are ...
- (Problem 74)Digit factorial chains
The number 145 is well known for the property that the sum of the factorial of its digits is equal t ...
- (Problem 33)Digit canceling fractions
The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...
- (Problem 13)Large sum
Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 371072875339 ...
- (Problem 46)Goldbach's other conjecture
It was proposed by Christian Goldbach that every odd composite number can be written as the sum of a ...
- (Problem 29)Distinct powers
Consider all integer combinations ofabfor 2a5 and 2b5: 22=4, 23=8, 24=16, 25=32 32=9, 33=27, 34=81, ...
- (Problem 28)Number spiral diagonals
Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is forme ...
随机推荐
- 【转】IOS 输入框被键盘遮盖的解决方法
做IOS开发时,难免会遇到输入框被键盘遮掩的问题.上网上搜索了很多相关的解决方案,看了很多,但是由衷的觉得太麻烦了. 有的解决方案是将视图上的所有的东西都添加到一个滚动视图对象( UIScrollVi ...
- [转]swift 学习资源 大集合
今天看到了一个swift的学习网站,里面收集了很多学习资源 [转自http://blog.csdn.net/sqc3375177/article/details/29206779] Swift 介绍 ...
- 为Chrome添加https搜索 自定义地址栏搜索引擎
转载 http://www.appinn.com/chrome-search-https-google/ 还可以参考一下 ://www.cnblogs.com/iftreasure/archive/2 ...
- 给定一个字符串里面只有"R" "G" "B" 三个字符,请排序,最终结果的顺序是R在前 G中 B在后。 要求:空间复杂度是O(1),且只能遍历一次字符串。
题目:给定一个字符串里面只有"R" "G" "B" 三个字符,请排序,最终结果的顺序是R在前 G中 B在后. 要求:空间复杂度是O(1),且 ...
- poj1144 Network【tarjan求割点】
转载请注明出处,谢谢:http://www.cnblogs.com/KirisameMarisa/p/4319585.html ---by 墨染之樱花 [题目链接]http://poj.org/p ...
- HA for openstack
mysql ha instance ha openstack博客:http://blog.csdn.net/tantexian/article/list/2 使用eclipse远程调试openstac ...
- probing元素
https://msdn.microsoft.com/zh-cn/library/823z9h8w(v=vs.85).aspx 指定加载程序集时公共语言运行库要搜索的应用程序基子目录. <con ...
- js动画学习(四)
七.多属性封装函数 前面分别介绍了单独改变单一属性值得动画,从本节起开始介绍多属性封装函数,一个函数搞定多种属性值的改变. 首先介绍一个很重要的函数getStyle(),这个函数返回一个元素的当前属性 ...
- 数据库基础(子查询练习、链接查询(join on 、union)及其练习)
子查询练习一:查询销售部里的年龄大于35岁的人的所有信息 练习二:将haha表中部门的所有数字代码转换为bumen表中的字符串显示 练习三:将haha表中部门的所有数字代码转换为bumen表中的字符串 ...
- VC++6.0打开文件出错的解决办法
1.下载http://support.microsoft.com/kb/241396里面的一个叫FileTool.exe的文件并解压,解压后是一个vc工程,用vc6.0打开工程,编译,得到FileTo ...