(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 ...
随机推荐
- linux如何关闭selinux?
首先我们可以用命令来查看selinux的状态getenforce 这个命令可以查看到selinux的状态,当前可以看到是关闭状态的.还有一个命令也可以查看出selinux的状态.sestatus -v ...
- 几款Http小服务器
六款小巧的HTTP Server[C语言] http://blog.linuxphp.org/?action=show&id=60 转载:
- ElasticSearch 插件配置
http://blog.sina.com.cn/s/blog_8f31e5b10101dsnq.html http://www.tuicool.com/articles/mMZfu2 http://b ...
- mongodb 学习初探
1.去mongodb 官方下载 http://www.mongodb.org/downloads 2.下载php的mongodb扩展 http://files.cnblogs.com/lsl8966/ ...
- Microsoft Accelerator for Windows Azure Alum Azuqua 今天启动
云最大的一个优势就是,它使开发人员比以往任何时候都更迅速.更灵活.在 Windows Azure 中开发应用程序时,工程师无需考虑架设服务器.规划容量或进行日常维护.相反,他们可以专注于提出假设 ...
- HDU 1089 A+B for Input-Output Practice (I)
#include <cstdio> int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) prin ...
- BZOJ 3402: [Usaco2009 Open]Hide and Seek 捉迷藏
题目 3402: [Usaco2009 Open]Hide and Seek 捉迷藏 Time Limit: 3 Sec Memory Limit: 128 MB Description 贝 ...
- javadoc入门
斌斌 (给我写信) 原创博文(http://blog.csdn.net/binbinxyz),转载请注明出处! java凝视 java里面有两种类型的凝视.一种是以"/*"起头,以 ...
- oracle 分组后取每组第一条数据
‘数据格式 分组取第一条的效果 sql SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY x ORDER BY y DESC) rn, test ...
- 使CSS3样式在IE里面有效果
1. 下载ie-css3.htc文件 2. 当前元素一定要有定位属性,像是position:relative或是position:absolute属性. 3. z-index值一定要比周围元素的要高 ...