(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 ...
随机推荐
- 射频识别技术漫谈(7)——ID卡
ID(Identification)是识别的意思,ID卡就是识别卡.ID卡包含范围广泛,只要具有识别功能的卡片都可以叫ID卡,例如条码卡,磁卡都可以是ID卡,我们这儿说的当然是射频识别卡. 射频ID卡 ...
- php如何在原来的时间上加一天?一小时
php如何在原来的时间上加一天?一小时? <?phpecho "今天:",date('Y-m-d H:i:s'),"<br>";echo &q ...
- kinect for windows - SkeletonBasics-D2D详解之二
首先看骨骼追踪例子代码的结构:
- linux 进程间信号量管理程序之sem_timedwait使用
在开发过程中,有三个独立执行的程序模块,三个模块都对sqlite数据库进行读写操作.sqlite在linux共享性较差,所以须要增加相互排斥信号量解决三个模块訪问数据库该问题. 另外,在增加信号量后, ...
- POJ1062 昂贵的聘礼 【DFS】
昂贵的聘礼 Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 37475 Accepted: 10816 Descripti ...
- Objective-c Category(类别)
category是Objective-c里面最常用的功能之一. category可以为已经存在的类增加方法,而不需要增加一个子类. 类别接口的标准语法格式如下: #import "类名.h& ...
- Linux-中断和中断处理
1.中断 #中断使得硬件得以发出通知给处理器,本质上是一种电信号 #中断随时能够产生.内核随时会被打断 #不同设备的中断不同,每一个中断都通过一个唯一的数字标识.称为IRQ(中断请求) 2.中断处理程 ...
- 建立&修改视图
一.建立视图 IF OBJECT_ID('Sales.OrderTotalsByYear', 'V') IS NOT NULL DROP VIEW Sales.OrderTotalsByYear; G ...
- [Swust OJ 795]--Penney Game
题目链接:http://acm.swust.edu.cn/problem/795/ Time limit(ms): 1000 Memory limit(kb): 65535 Description ...
- C++中(int&)和(int)的区别
在说这个问题之前,先说两个需要知道的背景知识: (1)语言的类型的强制转换不会修改原来的数据,会另外的开辟一个临时的或者程序中指定的空间来存储强制转换后的值. (2)C++引用的实现是在符号表中动了手 ...