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 的各位数之和是多少?

  1. // (Problem 16)Power digit sum
  2. // Completed on Sun, 17 Nov 2013, 15:23
  3. // Language: C
  4. //
  5. // 版权所有(C)acutus (mail: acutus@126.com)
  6. // 博客地址:http://www.cnblogs.com/acutus/
  7. #include <stdio.h>
  8. #include <stdbool.h>
  9.  
  10. void solve(void)
  11. {
  12. int a[] = {};
  13. int n, sum, i, j;
  14. n = sum = ;
  15. a[] = ;
  16. for(i = ; i < ; i++) { //以1000进制的方法存储
  17. for(j = ; j <= n; j++) {
  18. a[j] *= ;
  19. }
  20. for(j = ; j <= n; j++) {
  21. if(a[j] >= ) {
  22. a[j] %= ;
  23. a[j+]++;
  24. n++;
  25. }
  26. }
  27. }
  28. for(i = ; i <= n; i++) {
  29. sum += a[i] / ;
  30. a[i] %= ;
  31. sum += a[i] / ;
  32. a[i] %= ;
  33. sum += a[i] / ;
  34. a[i] %= ;
  35. sum += a[i] / ;
  36. a[i] %= ;
  37. sum += a[i];
  38.  
  39. }
  40. printf("%d\n",sum);
  41. }
  42.  
  43. int main(void)
  44. {
  45. solve();
  46. return ;
  47. }
Answer:
1366

(Problem 16)Power digit sum的更多相关文章

  1. project euler 16:Power digit sum

    >>> sum([int(i) for i in str(2**1000)]) 1366 >>>

  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. (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 ...

  4. (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 ...

  5. (Problem 33)Digit canceling fractions

    The fraction 49/98 is a curious fraction, as an inexperienced mathematician in attempting to simplif ...

  6. (Problem 13)Large sum

    Work out the first ten digits of the sum of the following one-hundred 50-digit numbers. 371072875339 ...

  7. (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 ...

  8. (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, ...

  9. (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 ...

随机推荐

  1. linux如何关闭selinux?

    首先我们可以用命令来查看selinux的状态getenforce 这个命令可以查看到selinux的状态,当前可以看到是关闭状态的.还有一个命令也可以查看出selinux的状态.sestatus -v ...

  2. 几款Http小服务器

    六款小巧的HTTP Server[C语言] http://blog.linuxphp.org/?action=show&id=60 转载:

  3. ElasticSearch 插件配置

    http://blog.sina.com.cn/s/blog_8f31e5b10101dsnq.html http://www.tuicool.com/articles/mMZfu2 http://b ...

  4. mongodb 学习初探

    1.去mongodb 官方下载 http://www.mongodb.org/downloads 2.下载php的mongodb扩展 http://files.cnblogs.com/lsl8966/ ...

  5. Microsoft Accelerator for Windows Azure Alum Azuqua 今天启动

     云最大的一个优势就是,它使开发人员比以往任何时候都更迅速.更灵活.在 Windows Azure 中开发应用程序时,工程师无需考虑架设服务器.规划容量或进行日常维护.相反,他们可以专注于提出假设 ...

  6. HDU 1089 A+B for Input-Output Practice (I)

    #include <cstdio> int main() { int a,b; while(scanf("%d%d",&a,&b)!=EOF) prin ...

  7. BZOJ 3402: [Usaco2009 Open]Hide and Seek 捉迷藏

    题目 3402: [Usaco2009 Open]Hide and Seek 捉迷藏 Time Limit: 3 Sec  Memory Limit: 128 MB Description     贝 ...

  8. javadoc入门

    斌斌 (给我写信) 原创博文(http://blog.csdn.net/binbinxyz),转载请注明出处! java凝视 java里面有两种类型的凝视.一种是以"/*"起头,以 ...

  9. oracle 分组后取每组第一条数据

    ‘数据格式 分组取第一条的效果 sql SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION BY x ORDER BY y DESC) rn, test ...

  10. 使CSS3样式在IE里面有效果

    1. 下载ie-css3.htc文件 2. 当前元素一定要有定位属性,像是position:relative或是position:absolute属性. 3. z-index值一定要比周围元素的要高 ...