(Problem 16)Power digit sum

时间:2022-06-11 01:45:00

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的更多相关文章

  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&&num;39&semi;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下安装Flask开发框架

    Flask是开发pythonweb的一个轻量级框架,适合初学者使用,当有了熟练的web基础后,再继续学习高级框架的开发,Linux一般安装好之后都会有python开发环境,给开发带来方便,下面是Fla ...

  2. 使用AJAX做关键字查询:输入框变化自动搜索、无刷新页面&semi;

    使用AJAX做关键字查询要求:1.无刷新页面2.输入框变化自动搜索 <style type="text/css"> .k{ width:150px; height:30 ...

  3. Path文件操作实例

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="AddProduct.asp ...

  4. c语言学习之基础知识点介绍(九):预处理指令和多文件开发

    一:预处理指令 /* 预处理指令: 作用:在程序编译之前做一些操作. 预处理命令写法的共同特点:都是以#号开头. 文件包含指令:#include 是一个文件包含命令. 作用:把某个文件内的内容读取出来 ...

  5. SQL 时间戳

    一直对时间戳这个概念比较模糊,相信有很多朋友也都会误认为:时间戳是一个时间字段,每次增加数据时,填入当前的时间值.其实这误导了很多朋友. 1.基本概念 时间戳:数据库中自动生成的唯一二进制数字,与时间 ...

  6. display:block&semi;inline&semi;inline-block大总结

    总体概念 block和inline这两个概念是简略的说法,完整确切的说应该是 block-level elements (块级元素) 和 inline elements (内联元素).block元素通 ...

  7. C#枚举中使用Flags特性

    如果对一个值可以包含多个,那么可以使用枚举,加上Flags 本文告诉大家如何写一个 Flags. 在写前,需要知道一些基础知识,取反.或.与,如果不知道的话,请去看看基础. 当然,这些太复杂了,我也不 ...

  8. 胜利大逃亡&lpar;续&rpar;(bfs&plus;状态压缩)

    胜利大逃亡(续) Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  9. &period;NET开发微信小程序-接收微信支付回调数据

    获取微信支付传回来的数据 1.MVC控制器 /// <summary> /// 付款返回的数据 /// </summary> /// <returns></r ...

  10. 【CH1602】最大异或和 trie&plus;贪心

    题目大意:给定 N 个数,求这 N 个数中任选两个数进行异或运算,求最大的异或和是多少. 一个 int 类型的整数,可以看作一个长度为32位的字符串,异或运算不像加法,最大值不一定是由两个较大值得到. ...