(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 ...
随机推荐
- Qt实战之开发软件数据获取助手(eventFilter处理鼠标按下,event处理鼠标松开)
前段时间,受朋友委托,需要做一个能够获取别人软件文本框中内容的助手.当然这需要调用win api来解决问题.一开始,我想都没想,就用getWindowText()....居然没用,好郁闷.于是查msd ...
- C++标准程序库的输入输出流(I/O Stream)复制文件(4种方法)
使用C++标准程序库的输入输出流(I/O Stream)复制文件,存在许多的方法, 方法一:逐个字符复制#include < fstream > std::ifstream ...
- web应用中Spring ApplicationContext的动态更新
在web应用中时常需要修改配置,并动态的重新加载ApplicationContext.比如,设置和切换数据库.以下给出一个方法,并通过代码验证可行性. 方法的基本思路是,为WebApplication ...
- 表格java代码的相关知识积累
本文主要收集各大博客中的java表格 用JSP创建一个表格模板 . 项目中要用到一些展示信息的表格,表头不固定,表格内容是即时从后台取的:考虑到复用性,笔者用jsp编写了一个表格模板,可以从reque ...
- SPOJ1811最长公共子串问题(后缀自动机)
题目:http://www.spoj.com/problems/LCS/ 题意:给两个串A和B,求这两个串的最长公共子串. 分析:其实本题用后缀数组的DC3已经能很好的解决,这里我们来说说利用后缀自动 ...
- Ants(思维)
Ants Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 12893 Accepted: 5637 Description ...
- Objective-c 类接口 (@interface) (类定义)
在Objective-c中如何定义一个类呢?我们可以使用下面的格式进行表示: @interface 类名:父类名{ 变量定义; } 方法定义: @end; 下面给出一个实例: @interface P ...
- ThinkPHP第三天(公共函数Common加载,dump定义,模板文件,定义替换__PUBLIC__)
1.公共函数定义 自动加载:在项目的common文件夹中定义,公共函数文件命名规则为common.php,只有命名成common.php才能被自动载入. 动态加载:可以修改配置项‘LOAD_EXT_F ...
- zookeeper 安装
Zookeeper安装 一. 下载zookeeper http://www.apache.org/dist/zookeeper/stable/ 二. 解压zookeeper.tar >& ...
- jQuery File Upload blueimp with struts2 简单试用
Official Site的话随便搜索就可以去了 另外新版PHP似乎都有问题 虽然图片都可以上传 但是response报错 我下载的是8.8.7木有问题 但是8.8.7版本结合修改main. ...