ENG  RUS Timus Online Judge
Online Judge
Problems
Authors
Online contests
Site news
Webboard
Problem set
Submit solution
Judge status
Guide
Register
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

## Discussion of Problem 1206. Sum of Digits of the Sum of Numbers

Posted by Anastas 1 Sep 2007 14:07
Just use long arithmetics and calculate 36*pow(55,k-1);
Posted by jagatsastry 16 Oct 2007 00:45
How did u get the formula
Posted by jagatsastry 16 Oct 2007 01:02
What are the libraries and functions u use for long arithmetic in c++.
Posted by MAT 23 Feb 2008 23:52
There are no such libraries! You must write long arithmetics by yourself ;)
Re: Or find somewhere... (+)
Posted by Aleksa_Markoni 27 Nov 2008 03:44
Thank finaly something extra ordinary good.
Thanks allot. I was searching for this for so long time. Thanks, thanks, thanks...
Posted by IgorKoval(from Pskov) 23 Nov 2011 03:01
This program explain how get 36 and 55.

#include <iostream>
using namespace std;

__int64 s( __int64 x ){
__int64 ans = 0;
while( x ){
ans += x % 10;
x /= 10;
}
return ans;
}

int main(){
__int64 kol = 0;
for( __int64 i = 0; i <= 9; ++i ){
for( __int64 j = 0; j <= 9; ++j ){
if( s(i+j) == s(i)+s(j) && i+j<=9 ){
cout << "    " << i << " " << j << "        s=" << s(i+j) << endl;
++kol;
}
}
cout << "-------------------------" << endl;
}
cout
<< "kol = "
<< kol << endl;

kol = 0;
for( __int64 i = 1; i <= 9; ++i ){// последний разряд без нулей т.к. число must be без ведущих нулей
for( __int64 j = 1; j <= 9; ++j ){
if( s(i+j) == s(i)+s(j) && i+j<=9 ){
cout << "    " << i << " " << j << "        s=" << s(i+j) << endl;
++kol;
}
}
cout << "-------------------------" << endl;
}
cout
<< "kol = "
<< kol << endl;
return 0;
}

Edited by author 23.11.2011 03:11

Edited by author 23.11.2011 03:12

Edited by author 23.11.2011 03:12