Project Euler problem 16

This commit is contained in:
2014-11-16 00:37:56 +04:00
parent 103e3a2298
commit 454ec923c0

View File

@@ -1,30 +1,23 @@
/* Check cf5-opt.vim defs. #Power digit sum
VIM: let g:lcppflags="-std=c++11 -O2 -pthread" #Problem 16
VIM: let g:wcppflags="/O2 /EHsc /DWIN32" #
VIM: let g:argv="" #215 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
VIM-: let g:cf5output=0 #
*/ #What is the sum of the digits of the number 21000?
#include <iostream>
#include <exception>
/*
*/
int main ( void ) pp = 1000
{try{
return 0; c = [0 for i in range(0, pp//3+1)]
} c[0] = 1
catch ( const std::exception& e )
{
std::cerr << std::endl
<< "std::exception(\"" << e.what() << "\")." << std::endl;
return 2;
}
catch ( ... )
{
std::cerr << std::endl
<< "unknown exception." << std::endl;
return 1;
}}
for i in range(0,pp):
r = 0
for j in range(0,len(c)):
p = c[j]*2+r
r = p//10
c[j] = p%10
s = 0
for i in c:
s += i
print( s )