(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 ...
随机推荐
- chrome dev tools
chrome dev tools介绍一下Chrome dev tools 的基本使用和一些意想不到的小技巧.\\Chrome Developer Tools 是Chrome内嵌的一系列编辑和调试的工具 ...
- cout输出流的执行顺序
一道题目: #include <iostream> using namespace std; ; template<typename T> int foo() { int va ...
- 17.1.2?Replication Formats 复制格式:
17.1.2?Replication Formats 复制格式: 17.1.2.1 Advantages and Disadvantages of Statement-Based and Row-Ba ...
- Hello China操作系统STM32移植指南(二)
移植步骤详解 下面就以MDK 4.72为开发环境,详细说明Hello China内核向STM32的移植过程.MDK 4.72评估版只支持32K代码的编译,这对Hello China的内核来说,裁剪掉一 ...
- poj 1050 To the Max(线性dp)
题目链接:http://poj.org/problem?id=1050 思路分析: 该题目为经典的最大子矩阵和问题,属于线性dp问题:最大子矩阵为最大连续子段和的推广情况,最大连续子段和为一维问题,而 ...
- River Hopscotch(二分最大化最小值)
River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9923 Accepted: 4252 D ...
- 在CheckBox中,仅仅允许选择一项
作用相当于RadioButonList <html xmlns="http://www.w3.org/1999/xhtml"> <head runat=" ...
- 关闭Outlook的时候使之最小化
Outlook很搓的一点就是只有按‘最小化’按钮的时候才会最小化到托盘,而按‘关闭’按钮Outlook直接被关闭退出.然后经常发现没邮件,结果是因为客户端关掉了. 下面通过插件方式实现关闭后最小化到托 ...
- LeetCode 二叉树的最小深度
计算二叉树的最小深度.最小深度定义为从root到叶子节点的最小路径. public class Solution { public int run(TreeNode root) { if(root = ...
- Android发送数据到web服务器4种方式
1./** 2. * Android中向web服务器提交数据的两种方式四种方法 3. */ 4.public class SubmitDataByHttpClientAndOrdinaryWay { ...